mirror of
https://github.com/debauchee/barrier.git
synced 2024-12-27 13:16:11 +03:00
Conflicts:
src/lib/server/ClientListener.cpp
This commit is contained in:
parent
e1be67cfb6
commit
3df75f9601
@ -108,6 +108,7 @@ REGISTER_EVENT(OSXScreen, confirmSleep)
|
|||||||
// ClientListener
|
// ClientListener
|
||||||
//
|
//
|
||||||
|
|
||||||
|
REGISTER_EVENT(ClientListener, accepted)
|
||||||
REGISTER_EVENT(ClientListener, connected)
|
REGISTER_EVENT(ClientListener, connected)
|
||||||
|
|
||||||
//
|
//
|
||||||
|
@ -337,11 +337,19 @@ private:
|
|||||||
class ClientListenerEvents : public EventTypes {
|
class ClientListenerEvents : public EventTypes {
|
||||||
public:
|
public:
|
||||||
ClientListenerEvents() :
|
ClientListenerEvents() :
|
||||||
|
m_accepted(Event::kUnknown),
|
||||||
m_connected(Event::kUnknown) { }
|
m_connected(Event::kUnknown) { }
|
||||||
|
|
||||||
//! @name accessors
|
//! @name accessors
|
||||||
//@{
|
//@{
|
||||||
|
|
||||||
|
//! Get accepted event type
|
||||||
|
/*!
|
||||||
|
Returns the accepted event type. This is sent whenever a server
|
||||||
|
accepts a client.
|
||||||
|
*/
|
||||||
|
Event::Type accepted();
|
||||||
|
|
||||||
//! Get connected event type
|
//! Get connected event type
|
||||||
/*!
|
/*!
|
||||||
Returns the connected event type. This is sent whenever a
|
Returns the connected event type. This is sent whenever a
|
||||||
@ -352,6 +360,7 @@ public:
|
|||||||
//@}
|
//@}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Event::Type m_accepted;
|
||||||
Event::Type m_connected;
|
Event::Type m_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -662,6 +662,7 @@ SecureSocket::serviceAccept(ISocketMultiplexerJob* job,
|
|||||||
|
|
||||||
// If status > 0, success
|
// If status > 0, success
|
||||||
if (status > 0) {
|
if (status > 0) {
|
||||||
|
sendEvent(m_events->forClientListener().accepted());
|
||||||
return newJob();
|
return newJob();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,6 +56,12 @@ ClientListener::ClientListener(const NetworkAddress& address,
|
|||||||
|
|
||||||
m_listen = m_socketFactory->createListen(m_useSecureNetwork);
|
m_listen = m_socketFactory->createListen(m_useSecureNetwork);
|
||||||
|
|
||||||
|
// setup event handler
|
||||||
|
m_events->adoptHandler(m_events->forIListenSocket().connecting(),
|
||||||
|
m_listen,
|
||||||
|
new TMethodEventJob<ClientListener>(this,
|
||||||
|
&ClientListener::handleClientConnecting));
|
||||||
|
|
||||||
// bind listen address
|
// bind listen address
|
||||||
LOG((CLOG_DEBUG1 "binding listen socket"));
|
LOG((CLOG_DEBUG1 "binding listen socket"));
|
||||||
m_listen->bind(address);
|
m_listen->bind(address);
|
||||||
@ -71,11 +77,6 @@ ClientListener::ClientListener(const NetworkAddress& address,
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
LOG((CLOG_DEBUG1 "listening for clients"));
|
LOG((CLOG_DEBUG1 "listening for clients"));
|
||||||
|
|
||||||
// setup event handler
|
|
||||||
m_events->adoptHandler(m_events->forIListenSocket().connecting(), m_listen,
|
|
||||||
new TMethodEventJob<ClientListener>(this,
|
|
||||||
&ClientListener::handleClientConnecting));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ClientListener::~ClientListener()
|
ClientListener::~ClientListener()
|
||||||
@ -142,38 +143,43 @@ ClientListener::handleClientConnecting(const Event&, void*)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
m_events->adoptHandler(m_events->forClientListener().accepted(),
|
||||||
|
stream->getEventTarget(),
|
||||||
|
new TMethodEventJob<ClientListener>(this,
|
||||||
|
&ClientListener::handleClientAccepted, stream));
|
||||||
|
|
||||||
|
// When using non SSL, server accepts clients immediately, while SSL
|
||||||
|
// has to call secure accept which may require retry
|
||||||
|
if (!m_args.m_enableCrypto) {
|
||||||
|
m_events->addEvent(Event(m_events->forClientListener().accepted(),
|
||||||
|
stream));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ClientListener::handleClientAccepted(const Event&, void* vstream)
|
||||||
|
{
|
||||||
LOG((CLOG_NOTE "accepted client connection"));
|
LOG((CLOG_NOTE "accepted client connection"));
|
||||||
|
|
||||||
if (m_useSecureNetwork) {
|
synergy::IStream* stream = reinterpret_cast<synergy::IStream*>(vstream);
|
||||||
LOG((CLOG_DEBUG2 "attempting sercure Connection"));
|
IDataSocket* socket = dynamic_cast<IDataSocket*>(stream);
|
||||||
while (!socket->isReady()) {
|
|
||||||
if (socket->isFatal()) {
|
|
||||||
m_listen->deleteSocket(socket);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
LOG((CLOG_DEBUG2 "retrying sercure Connection"));
|
|
||||||
ARCH->sleep(.5f);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
LOG((CLOG_DEBUG2 "sercure Connection established:%d"));
|
|
||||||
|
|
||||||
synergy::IStream* stream = socket;
|
|
||||||
// filter socket messages, including a packetizing filter
|
// filter socket messages, including a packetizing filter
|
||||||
bool adopt = !m_useSecureNetwork;
|
stream = new PacketStreamFilter(m_events, socket);
|
||||||
stream = new PacketStreamFilter(m_events, stream, adopt);
|
|
||||||
|
|
||||||
assert(m_server != NULL);
|
assert(m_server != NULL);
|
||||||
|
|
||||||
// create proxy for unknown client
|
// create proxy for unknown client
|
||||||
ClientProxyUnknown* client = new ClientProxyUnknown(stream, 30.0, m_server, m_events);
|
ClientProxyUnknown* client = new ClientProxyUnknown(stream, 30.0, m_server, m_events);
|
||||||
|
|
||||||
m_newClients.insert(client);
|
m_newClients.insert(client);
|
||||||
|
|
||||||
// watch for events from unknown client
|
// watch for events from unknown client
|
||||||
m_events->adoptHandler(m_events->forClientProxyUnknown().success(), client,
|
m_events->adoptHandler(m_events->forClientProxyUnknown().success(),
|
||||||
|
client,
|
||||||
new TMethodEventJob<ClientListener>(this,
|
new TMethodEventJob<ClientListener>(this,
|
||||||
&ClientListener::handleUnknownClient, client));
|
&ClientListener::handleUnknownClient, client));
|
||||||
m_events->adoptHandler(m_events->forClientProxyUnknown().failure(), client,
|
m_events->adoptHandler(m_events->forClientProxyUnknown().failure(),
|
||||||
|
client,
|
||||||
new TMethodEventJob<ClientListener>(this,
|
new TMethodEventJob<ClientListener>(this,
|
||||||
&ClientListener::handleUnknownClient, client));
|
&ClientListener::handleUnknownClient, client));
|
||||||
}
|
}
|
||||||
@ -193,7 +199,8 @@ ClientListener::handleUnknownClient(const Event&, void* vclient)
|
|||||||
if (client != NULL) {
|
if (client != NULL) {
|
||||||
// handshake was successful
|
// handshake was successful
|
||||||
m_waitingClients.push_back(client);
|
m_waitingClients.push_back(client);
|
||||||
m_events->addEvent(Event(m_events->forClientListener().connected(), this));
|
m_events->addEvent(Event(m_events->forClientListener().connected(),
|
||||||
|
this));
|
||||||
|
|
||||||
// watch for client to disconnect while it's in our queue
|
// watch for client to disconnect while it's in our queue
|
||||||
m_events->adoptHandler(m_events->forClientProxy().disconnected(), client,
|
m_events->adoptHandler(m_events->forClientProxy().disconnected(), client,
|
||||||
|
@ -69,6 +69,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
// client connection event handlers
|
// client connection event handlers
|
||||||
void handleClientConnecting(const Event&, void*);
|
void handleClientConnecting(const Event&, void*);
|
||||||
|
void handleClientAccepted(const Event&, void*);
|
||||||
void handleUnknownClient(const Event&, void*);
|
void handleUnknownClient(const Event&, void*);
|
||||||
void handleClientDisconnected(const Event&, void*);
|
void handleClientDisconnected(const Event&, void*);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user