fixed: ipc client running on synergyc wasn't sending hello message, and so wasn't getting shutdown message. edits to CIpcClient or CIpcTests weren't really needed, but looks slightly better this way maybe.

This commit is contained in:
Nick Bolton 2012-07-10 11:23:08 +00:00
parent 5be1fd0cfa
commit f9f04034c9
3 changed files with 28 additions and 17 deletions

View File

@ -29,23 +29,21 @@ m_serverAddress(CNetworkAddress(IPC_HOST, IPC_PORT)),
m_server(nullptr)
{
m_serverAddress.resolve();
EVENTQUEUE->adoptHandler(
m_socket.getConnectedEvent(), m_socket.getEventTarget(),
new TMethodEventJob<CIpcClient>(
this, &CIpcClient::handleConnected));
}
CIpcClient::~CIpcClient()
{
EVENTQUEUE->removeHandler(m_socket.getConnectedEvent(), m_socket.getEventTarget());
EVENTQUEUE->removeHandler(CIpcServerProxy::getMessageReceivedEvent(), m_server);
delete m_server;
disconnect();
}
void
CIpcClient::connect()
{
EVENTQUEUE->adoptHandler(
IDataSocket::getConnectedEvent(), m_socket.getEventTarget(),
new TMethodEventJob<CIpcClient>(
this, &CIpcClient::handleConnected));
m_socket.connect(m_serverAddress);
m_server = new CIpcServerProxy(m_socket);
@ -58,6 +56,9 @@ CIpcClient::connect()
void
CIpcClient::disconnect()
{
EVENTQUEUE->removeHandler(IDataSocket::getConnectedEvent(), m_socket.getEventTarget());
EVENTQUEUE->removeHandler(CIpcServerProxy::getMessageReceivedEvent(), m_server);
m_server->disconnect();
delete m_server;
m_server = nullptr;

View File

@ -528,13 +528,15 @@ CClientApp::mainLoop()
// create the event queue
CEventQueue eventQueue;
if (argsBase().m_enableIpc) {
initIpcClient();
}
// start client, etc
appUtil().startNode();
// init ipc client after node start, since create a new screen wipes out
// the event queue (the screen ctors call adoptBuffer).
if (argsBase().m_enableIpc) {
initIpcClient();
}
// load all available plugins.
ARCH->plugin().init(s_clientScreen->getEventTarget());

View File

@ -59,7 +59,9 @@ public:
CSocketMultiplexer m_multiplexer;
CEventQueue m_events;
CEventQueueTimer* m_quitTimeoutTimer;
bool m_connectToServer_clientConnected;
bool m_connectToServer_helloMessageReceived;
bool m_connectToServer_hasClientNode;
CIpcServer* m_connectToServer_server;
CString m_sendMessageToServer_receivedString;
CString m_sendMessageToClient_receivedString;
CIpcClient* m_sendMessageToServer_client;
@ -71,6 +73,7 @@ TEST_F(CIpcTests, connectToServer)
{
CIpcServer server;
server.listen();
m_connectToServer_server = &server;
m_events.adoptHandler(
CIpcServer::getMessageReceivedEvent(), &server,
@ -84,8 +87,9 @@ TEST_F(CIpcTests, connectToServer)
m_events.loop();
m_events.removeHandler(CIpcServer::getMessageReceivedEvent(), &server);
cleanupQuitTimeout();
EXPECT_EQ(true, m_connectToServer_clientConnected);
EXPECT_EQ(true, m_connectToServer_helloMessageReceived);
EXPECT_EQ(true, m_connectToServer_hasClientNode);
}
TEST_F(CIpcTests, sendMessageToServer)
@ -148,7 +152,9 @@ TEST_F(CIpcTests, sendMessageToClient)
CIpcTests::CIpcTests() :
m_quitTimeoutTimer(nullptr),
m_connectToServer_clientConnected(false),
m_connectToServer_helloMessageReceived(false),
m_connectToServer_hasClientNode(false),
m_connectToServer_server(nullptr),
m_sendMessageToClient_server(nullptr),
m_sendMessageToServer_client(nullptr)
{
@ -163,7 +169,9 @@ CIpcTests::connectToServer_handleMessageReceived(const CEvent& e, void*)
{
CIpcMessage* m = static_cast<CIpcMessage*>(e.getDataObject());
if (m->m_type == kIpcHello) {
m_connectToServer_clientConnected = true;
m_connectToServer_hasClientNode =
m_connectToServer_server->hasClients(kIpcClientNode);
m_connectToServer_helloMessageReceived = true;
raiseQuitEvent();
}
}