* @param[in] message The response message
*/
virtual void OnIpcResponseReceived(IpcClient& client, const IPC::Message& message) = 0;
+
+ /**
+ * Called when an IPC server disconnected.
+ *
+ * @param[in] client The IPC client
+ */
+ virtual void OnIpcServerDisconnected(IpcClient& client) {}
}; // IIpcClientEventListener
#endif //_IIPC_CLIENT_EVENT_LISTENER_H_
}
+string
+IpcClient::GetName(void) const
+{
+ return __name;
+}
+
struct HelloMessage
{
int pid;
if (condition & G_IO_HUP)
{
+ _LOGD("G_IO_HUP, the connection is closed.");
+
g_source_destroy(__pReverseSource);
g_source_unref(__pReverseSource);
__pReverseSource = NULL;
+ if (__pListener)
+ {
+ __pListener->OnIpcServerDisconnected(*this);
+ }
+
return FALSE;
}
else if (condition & G_IO_IN)
{
pGError = NULL;
status = g_io_channel_read_chars(source, (char*) __messageBuffer, __MAX_MESSAGE_BUFFER_SIZE, &readSize, &pGError);
- if (status == G_IO_STATUS_EOF)
+ if (status == G_IO_STATUS_EOF || status == G_IO_STATUS_ERROR)
{
+ if (status == G_IO_STATUS_EOF)
+ {
+ _LOGD("G_IO_STATUS_EOF, the connection is closed.");
+ }
+ else
+ {
+ _LOGD("G_IO_STATUS_ERROR, the connection is closed.");
+ }
+
pGError = NULL;
g_io_channel_shutdown(source, FALSE, &pGError);
g_source_unref(__pReverseSource);
__pReverseSource = NULL;
+ if (__pListener)
+ {
+ __pListener->OnIpcServerDisconnected(*this);
+ }
+
return FALSE;
}
int Construct(const std::string& serverName, const IIpcClientEventListener* pListener = NULL);
/**
+ * Returns the name of the IPC server.
+ *
+ * @return The name of the IPC server.
+ */
+ std::string GetName(void) const;
+
+ /**
* Sends a request message to an IPC server.
*
* @code