deskflow/src/lib/ipc/IpcClient.h

65 lines
1.7 KiB
C
Raw Normal View History

2012-06-28 07:29:06 +00:00
/*
* synergy -- mouse and keyboard sharing utility
* Copyright (C) 2012 Bolton Software Ltd.
2012-06-28 07:29:06 +00:00
* Copyright (C) 2012 Nick Bolton
*
* This package is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* found in the file COPYING that should have accompanied this file.
*
* This package is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once
#include "net/NetworkAddress.h"
#include "net/TCPSocket.h"
#include "base/EventTypes.h"
2012-07-02 15:28:23 +00:00
2014-11-11 13:51:47 +00:00
class IpcServerProxy;
class IpcMessage;
class IEventQueue;
2014-11-11 13:51:47 +00:00
class SocketMultiplexer;
2012-06-28 07:29:06 +00:00
//! IPC client for communication between daemon and GUI.
/*!
2014-11-11 13:51:47 +00:00
* See \ref IpcServer description.
2012-06-28 07:29:06 +00:00
*/
2014-11-11 13:51:47 +00:00
class IpcClient {
2012-06-28 07:29:06 +00:00
public:
2014-11-11 13:51:47 +00:00
IpcClient(IEventQueue* events, SocketMultiplexer* socketMultiplexer);
IpcClient(IEventQueue* events, SocketMultiplexer* socketMultiplexer, int port);
virtual ~IpcClient();
2012-06-28 07:29:06 +00:00
//! @name manipulators
//@{
2012-06-28 07:29:06 +00:00
//! Connects to the IPC server at localhost.
2012-07-02 13:45:52 +00:00
void connect();
//! Disconnects from the IPC server.
void disconnect();
2012-07-02 13:45:52 +00:00
//! Sends a message to the server.
2014-11-11 13:51:47 +00:00
void send(const IpcMessage& message);
//@}
private:
void init();
2014-11-11 13:51:47 +00:00
void handleConnected(const Event&, void*);
void handleMessageReceived(const Event&, void*);
private:
2014-11-11 13:51:47 +00:00
NetworkAddress m_serverAddress;
CTCPSocket m_socket;
2014-11-11 13:51:47 +00:00
IpcServerProxy* m_server;
IEventQueue* m_events;
2012-06-28 07:29:06 +00:00
};