: __pReverseSource(null)
, __fdCount(0)
, __pFdLock(null)
- , __name("")
, __pListener(null)
{
__messageBuffer[0] = '\0';
return E_SUCCESS;
CATCH:
- __name = "";
+ __name.Clear();
__pListener = null;
__pFdLock = null;
return r;
}
+String
+_IpcClient::GetName(void) const
+{
+ return __name;
+}
+
struct HelloMessage
{
int pid;
FD_ZERO(&rset);
FD_SET(client, &rset);
wset = rset;
- timeout.tv_sec = 10; // FIXME: replace 10 with const int
+ timeout.tv_sec = 10;
timeout.tv_usec = 0;
- // FIXME:
- // replace select with poll
while (true)
{
ret = select(client+1, &rset, &wset, NULL, &timeout);
if (condition & G_IO_HUP)
{
+ SysLog(NID_IO, "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)
+ {
+ SysLog(NID_IO, "G_IO_STATUS_EOF, the connection is closed.");
+ }
+ else
+ {
+ SysLog(NID_IO, "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;
}
/**
* @interface _IIpcClientEventListener
* @brief This interface provides the listener method for the response from IPC server.
- * since 3.0
*/
class _OSP_EXPORT_ _IIpcClientEventListener
: Tizen::Base::Runtime::IEventListener
/**
* This is the destructor for this class.
*
- * @since 2.1
*/
virtual ~_IIpcClientEventListener(void);
/**
* Called when an IPC response message received.
*
- * @since 2.1
* @param[in] client The IPC client
* @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
/**
* @interface _IIpcServerEventListener
* @brief This interface provides listener method for the request event from an IPC client.
- * since 3.0
*/
class _OSP_EXPORT_ _IIpcServerEventListener
: virtual Tizen::Base::Runtime::IEventListener
public:
/**
* This is the destructor for this class.
- *
- * @since 2.1
*/
virtual ~_IIpcServerEventListener(void);
/**
* Called when an IPC server started.
*
- * @since 2.1
* @param[in] server The IPC server
*/
virtual void OnIpcServerStarted(const _IpcServer& server) = 0;
/**
* Called when an IPC server stopped.
*
- * @since 2.1
* @param[in] server The IPC server
*/
virtual void OnIpcServerStopped(const _IpcServer& server) = 0;
/**
* Called when an IPC client connected.
*
- * @since 2.1
* @param[in] server The IPC server
*/
virtual void OnIpcClientConnected(const _IpcServer& server, int clientId) = 0;
/**
* Called when an IPC client disconnected.
*
- * @since 2.1
* @param[in] server The IPC server
* @param[in] clientId The id of the connected IPC client
*/
/**
* Called when an IPC request message received.
*
- * @since 2.1
* @code
*
* bool
result Construct(const Tizen::Base::String& serverName, const _IIpcClientEventListener* pListener = null);
/**
+ * Returns the name of the IPC server.
+ *
+ * @return The name of the IPC server.
+ */
+ Tizen::Base::String GetName(void) const;
+
+ /**
* Sends a request message to an IPC server.
*
* @code
}
_IpcServer::_IpcServer(void)
- : __name("")
- , __runOnCallerThread(false)
+ : __runOnCallerThread(false)
, __pEventDispatcher(null)
, __pListener(null)
, __handlerThread(0)
return E_SUCCESS;
CATCH:
+ __name.Clear();
+
if (pGIOChannel != null)
{
g_io_channel_unref(pGIOChannel);
if (condition & G_IO_HUP)
{
- SysLog(NID_IO, "Connection closed");
+ SysLog(NID_IO, "G_IO_HUP, the connection is closed.");
+
int clientId = pClientInfo->clientId;
g_io_channel_shutdown(source, FALSE, &pGError);