2012-06-28 07:29:06 +00:00
|
|
|
/*
|
|
|
|
|
* synergy -- mouse and keyboard sharing utility
|
|
|
|
|
* 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
|
|
|
|
|
|
2012-07-02 13:45:52 +00:00
|
|
|
#include "CEvent.h"
|
2012-07-05 18:05:35 +00:00
|
|
|
#include "Ipc.h"
|
2012-07-06 16:18:21 +00:00
|
|
|
#include "IArchMultithread.h"
|
2012-07-02 13:45:52 +00:00
|
|
|
|
2012-07-05 18:05:35 +00:00
|
|
|
namespace synergy { class IStream; }
|
2012-07-02 15:28:23 +00:00
|
|
|
class CIpcMessage;
|
2012-07-10 01:51:51 +00:00
|
|
|
class CIpcCommandMessage;
|
|
|
|
|
class CIpcHelloMessage;
|
2012-07-01 21:18:21 +00:00
|
|
|
|
2012-06-28 07:29:06 +00:00
|
|
|
class CIpcClientProxy {
|
2012-07-10 01:51:51 +00:00
|
|
|
friend class CIpcServer;
|
|
|
|
|
|
2012-06-28 07:29:06 +00:00
|
|
|
public:
|
2012-07-05 18:05:35 +00:00
|
|
|
CIpcClientProxy(synergy::IStream& stream);
|
2012-06-28 07:29:06 +00:00
|
|
|
virtual ~CIpcClientProxy();
|
2012-07-01 21:18:21 +00:00
|
|
|
|
2012-07-10 01:51:51 +00:00
|
|
|
private:
|
2012-07-02 15:28:23 +00:00
|
|
|
//! Send a message to the client.
|
2012-07-05 18:05:35 +00:00
|
|
|
void send(const CIpcMessage& message);
|
2012-07-02 15:28:23 +00:00
|
|
|
|
2012-07-02 13:45:52 +00:00
|
|
|
//! Raised when the server receives a message from a client.
|
2012-07-05 18:05:35 +00:00
|
|
|
static CEvent::Type getMessageReceivedEvent();
|
2012-07-02 13:45:52 +00:00
|
|
|
|
2012-07-06 12:27:22 +00:00
|
|
|
//! Raised when the client disconnects from the server.
|
|
|
|
|
static CEvent::Type getDisconnectedEvent();
|
|
|
|
|
|
2012-07-02 13:45:52 +00:00
|
|
|
void handleData(const CEvent&, void*);
|
2012-07-06 12:27:22 +00:00
|
|
|
void handleDisconnect(const CEvent&, void*);
|
|
|
|
|
void handleWriteError(const CEvent&, void*);
|
2012-07-10 01:51:51 +00:00
|
|
|
CIpcHelloMessage* parseHello();
|
|
|
|
|
CIpcCommandMessage* parseCommand();
|
2012-07-02 13:45:52 +00:00
|
|
|
void disconnect();
|
2012-07-10 01:51:51 +00:00
|
|
|
|
|
|
|
|
private:
|
2012-07-05 18:05:35 +00:00
|
|
|
synergy::IStream& m_stream;
|
|
|
|
|
EIpcClientType m_clientType;
|
2012-07-06 12:27:22 +00:00
|
|
|
bool m_disconnecting;
|
2012-07-09 12:09:24 +00:00
|
|
|
CArchMutex m_readMutex;
|
|
|
|
|
CArchMutex m_writeMutex;
|
2012-07-06 14:46:46 +00:00
|
|
|
|
2012-07-02 13:45:52 +00:00
|
|
|
static CEvent::Type s_messageReceivedEvent;
|
2012-07-06 12:27:22 +00:00
|
|
|
static CEvent::Type s_disconnectedEvent;
|
2012-06-28 07:29:06 +00:00
|
|
|
};
|