aboutsummaryrefslogtreecommitdiff
path: root/src/server.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2008-02-07 19:01:12 +0000
committerMike Buland <eichlan@xagasoft.com>2008-02-07 19:01:12 +0000
commit9ab87f39d7fc37e52d742d38b191eed9128d4b5b (patch)
tree17a00529eda3d9a5a979c05d688f219f7af1631a /src/server.cpp
parent5574841cc88412854b2cb94253152b3606803e2a (diff)
downloadlibbu++-9ab87f39d7fc37e52d742d38b191eed9128d4b5b.tar.gz
libbu++-9ab87f39d7fc37e52d742d38b191eed9128d4b5b.tar.bz2
libbu++-9ab87f39d7fc37e52d742d38b191eed9128d4b5b.tar.xz
libbu++-9ab87f39d7fc37e52d742d38b191eed9128d4b5b.zip
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.
Diffstat (limited to '')
-rw-r--r--src/server.cpp31
1 files changed, 30 insertions, 1 deletions
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 )
109 FD_SET( nSocket, &fdActive ); 109 FD_SET( nSocket, &fdActive );
110 110
111 Client *c = new Client( 111 Client *c = new Client(
112 new Bu::Socket( nSocket ) 112 new Bu::Socket( nSocket ),
113 new SrvClientLinkFactory()
113 ); 114 );
114 hClients.insert( nSocket, c ); 115 hClients.insert( nSocket, c );
115 116
116 onNewConnection( c, nPort ); 117 onNewConnection( c, nPort );
117} 118}
118 119
120Bu::Server::SrvClientLink::SrvClientLink( Bu::Client *pClient ) :
121 pClient( pClient )
122{
123}
124
125Bu::Server::SrvClientLink::~SrvClientLink()
126{
127}
128
129void Bu::Server::SrvClientLink::sendMsg( const Bu::FString &sMsg )
130{
131 pClient->onMessage( sMsg );
132}
133
134Bu::Server::SrvClientLinkFactory::SrvClientLinkFactory()
135{
136}
137
138Bu::Server::SrvClientLinkFactory::~SrvClientLinkFactory()
139{
140}
141
142Bu::ClientLink *Bu::Server::SrvClientLinkFactory::createLink(
143 Bu::Client *pClient )
144{
145 return new SrvClientLink( pClient );
146}
147