From 9ab87f39d7fc37e52d742d38b191eed9128d4b5b Mon Sep 17 00:00:00 2001 From: Mike Buland Date: Thu, 7 Feb 2008 19:01:12 +0000 Subject: Wowee, I think all this new stuff works, Conduit I don't need now, so it's not done yet. The Client class now supports a function called getLink() which returns a ClientLink object. This object may then be passed off to any other class and called to send messages to that client object. It is threadsafe if ItoServer is being used, and not for Server. Sending a message via a ClientLink calls the onMessage function on the assosiated protocol. Note that sending messages from within protocol event handlers or functions they call, while safe, may be slow and it's reccomended that you avoid this. --- src/server.cpp | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'src/server.cpp') diff --git a/src/server.cpp b/src/server.cpp index 861e2e3..cca486a 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -109,10 +109,39 @@ void Bu::Server::addClient( int nSocket, int nPort ) FD_SET( nSocket, &fdActive ); Client *c = new Client( - new Bu::Socket( nSocket ) + new Bu::Socket( nSocket ), + new SrvClientLinkFactory() ); hClients.insert( nSocket, c ); onNewConnection( c, nPort ); } +Bu::Server::SrvClientLink::SrvClientLink( Bu::Client *pClient ) : + pClient( pClient ) +{ +} + +Bu::Server::SrvClientLink::~SrvClientLink() +{ +} + +void Bu::Server::SrvClientLink::sendMsg( const Bu::FString &sMsg ) +{ + pClient->onMessage( sMsg ); +} + +Bu::Server::SrvClientLinkFactory::SrvClientLinkFactory() +{ +} + +Bu::Server::SrvClientLinkFactory::~SrvClientLinkFactory() +{ +} + +Bu::ClientLink *Bu::Server::SrvClientLinkFactory::createLink( + Bu::Client *pClient ) +{ + return new SrvClientLink( pClient ); +} + -- cgit v1.2.3