X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=examples%2Frpc%2Frpc.cpp;h=a70e49ff9d7810b1b6d2df3e420eff5e70403cad;hb=3a034abb4dca58ff0940687d8dd2b829ce2e226f;hp=6991edba92145c506d7cd65af6ef5739caff84ff;hpb=58be0971049907f3166ce56a6ad509769565158f;p=framework%2Fweb%2Fwrt-commons.git diff --git a/examples/rpc/rpc.cpp b/examples/rpc/rpc.cpp index 6991edb..a70e49f 100644 --- a/examples/rpc/rpc.cpp +++ b/examples/rpc/rpc.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include #include static const char *RPC_NAME = "/tmp/unix_socket_rpc"; @@ -47,43 +47,43 @@ private: { (void)event; - LogDebug("CLIENT: AsyncCallEvent received"); + WrtLogD("CLIENT: AsyncCallEvent received"); int value; event.GetArg0().ConsumeArg(value); - LogDebug("CLIENT: Result from server: " << value); + WrtLogD("CLIENT: Result from server: %i", value); } virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::ConnectionClosedEvent &event) { (void)event; - LogDebug("CLIENT: ConnectionClosedEvent received"); + WrtLogD("CLIENT: ConnectionClosedEvent received"); } virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent &event) { (void)event; - LogDebug("CLIENT: ConnectionBrokenEvent received"); + WrtLogD("CLIENT: ConnectionBrokenEvent received"); } virtual void OnEventReceived(const DPL::AbstractRPCConnectorEvents::ConnectionEstablishedEvent &event) { // Save connection pointer - LogDebug("CLIENT: Acquiring new connection"); + WrtLogD("CLIENT: Acquiring new connection"); m_rpcConnection.reset(event.GetArg1()); // Attach listener to new connection - LogDebug("CLIENT: Attaching connection event listeners"); + WrtLogD("CLIENT: Attaching connection event listeners"); m_rpcConnection->DPL::EventSupport::AddListener(this); m_rpcConnection->DPL::EventSupport::AddListener(this); m_rpcConnection->DPL::EventSupport::AddListener(this); - LogDebug("CLIENT: Connection established"); + WrtLogD("CLIENT: Connection established"); // Emit RPC function call DPL::RPCFunction proc; proc.AppendArg((int)1111); - LogDebug("CLIENT: Calling RPC function"); + WrtLogD("CLIENT: Calling RPC function"); m_rpcConnection->AsyncCall(proc); } @@ -97,35 +97,35 @@ public: virtual int ThreadEntry() { // Attach RPC listeners - LogDebug("CLIENT: Attaching connection established event"); + WrtLogD("CLIENT: Attaching connection established event"); m_rpcClient.DPL::EventSupport::AddListener(this); // Open connection to server - LogDebug("CLIENT: Opening connection to RPC"); + WrtLogD("CLIENT: Opening connection to RPC"); m_rpcClient.Open(RPC_NAME); // Start message loop - LogDebug("CLIENT: Starting thread event loop"); + WrtLogD("CLIENT: Starting thread event loop"); int ret = Exec(); // Detach RPC listeners if (m_rpcConnection.get()) { - LogDebug("CLIENT: Detaching RPC connection events"); + WrtLogD("CLIENT: Detaching RPC connection events"); m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); - LogDebug("CLIENT: Resetting connection"); + WrtLogD("CLIENT: Resetting connection"); m_rpcConnection.reset(); } // Detach RPC client listener - LogDebug("CLIENT: Detaching connection established event"); + WrtLogD("CLIENT: Detaching connection established event"); m_rpcClient.DPL::EventSupport::RemoveListener(this); // Close RPC - LogDebug("CLIENT: Closing RPC client"); + WrtLogD("CLIENT: Closing RPC client"); m_rpcClient.CloseAll(); // Done @@ -168,61 +168,61 @@ private: { (void)event; - LogDebug("SERVER: AsyncCallEvent received"); + WrtLogD("SERVER: AsyncCallEvent received"); int value; event.GetArg0().ConsumeArg(value); - LogDebug("SERVER: Result from client: " << value); + WrtLogD("SERVER: Result from client: %i", value); } virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::ConnectionClosedEvent &event) { (void)event; - LogDebug("SERVER: ConnectionClosedEvent received"); + WrtLogD("SERVER: ConnectionClosedEvent received"); // Close RPC now - LogDebug("SERVER: Closing RPC connection on event..."); + WrtLogD("SERVER: Closing RPC connection on event..."); // Detach RPC connection listeners if (m_rpcConnection.get()) { - LogDebug("SERVER: Detaching connection events"); + WrtLogD("SERVER: Detaching connection events"); m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); m_rpcConnection->DPL::EventSupport::RemoveListener(this); } - LogDebug("SERVER: RPC connection closed"); + WrtLogD("SERVER: RPC connection closed"); - LogDebug("SERVER: Closing RPC on event..."); + WrtLogD("SERVER: Closing RPC on event..."); m_rpcServer.CloseAll(); - LogDebug("SERVER: RPC closed"); + WrtLogD("SERVER: RPC closed"); } virtual void OnEventReceived(const DPL::AbstractRPCConnectionEvents::ConnectionBrokenEvent &event) { (void)event; - LogDebug("SERVER: ConnectionBrokenEvent received"); + WrtLogD("SERVER: ConnectionBrokenEvent received"); } virtual void OnEventReceived(const DPL::AbstractRPCConnectorEvents::ConnectionEstablishedEvent &event) { // Save connection pointer - LogDebug("SERVER: Acquiring RPC connection"); + WrtLogD("SERVER: Acquiring RPC connection"); m_rpcConnection.reset(event.GetArg1()); // Attach event listeners - LogDebug("SERVER: Attaching connection listeners"); + WrtLogD("SERVER: Attaching connection listeners"); m_rpcConnection->DPL::EventSupport::AddListener(this); m_rpcConnection->DPL::EventSupport::AddListener(this); m_rpcConnection->DPL::EventSupport::AddListener(this); - LogDebug("SERVER: Connection established"); + WrtLogD("SERVER: Connection established"); // Emit RPC function call DPL::RPCFunction proc; proc.AppendArg((int)2222); - LogDebug("SERVER: Calling RPC function"); + WrtLogD("SERVER: Calling RPC function"); m_rpcConnection->AsyncCall(proc); } @@ -231,23 +231,23 @@ public: : Application(argc, argv, "rpc") { // Attach RPC server listeners - LogDebug("SERVER: Attaching connection established event"); + WrtLogD("SERVER: Attaching connection established event"); m_rpcServer.DPL::EventSupport::AddListener(this); // Self touch - LogDebug("SERVER: Touching controller"); + WrtLogD("SERVER: Touching controller"); Touch(); // Open RPC server - LogDebug("SERVER: Opening server RPC"); + WrtLogD("SERVER: Opening server RPC"); m_rpcServer.Open(RPC_NAME); // Run RPC client in thread - LogDebug("SERVER: Starting RPC client thread"); + WrtLogD("SERVER: Starting RPC client thread"); m_thread.Run(); // Quit application automatically in few seconds - LogDebug("SERVER: Sending control timed events"); + WrtLogD("SERVER: Sending control timed events"); DPL::ControllerEventHandler::PostTimedEvent(CloseThreadEvent(), 2); DPL::ControllerEventHandler::PostTimedEvent(QuitEvent(), 3); } @@ -255,11 +255,11 @@ public: virtual ~MyApplication() { // Quit thread - LogDebug("SERVER: Quitting thread"); + WrtLogD("SERVER: Quitting thread"); m_thread.Quit(); // Close RPC server - LogDebug("SERVER: Closing RPC server"); + WrtLogD("SERVER: Closing RPC server"); m_rpcServer.CloseAll(); // Detach RPC server listener @@ -269,7 +269,7 @@ public: int main(int argc, char *argv[]) { - LogDebug("Starting"); + WrtLogD("Starting"); MyApplication app(argc, argv); return app.Exec(); }