aboutsummaryrefslogtreecommitdiff
path: root/src/client.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/client.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 'src/client.cpp')
-rw-r--r--src/client.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/client.cpp b/src/client.cpp
index 1ef9151..d1eb29c 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -11,15 +11,18 @@
11#include <errno.h> 11#include <errno.h>
12#include "bu/exceptions.h" 12#include "bu/exceptions.h"
13#include "bu/protocol.h" 13#include "bu/protocol.h"
14#include "bu/clientlink.h"
15#include "bu/clientlinkfactory.h"
14 16
15/** Read buffer size. */ 17/** Read buffer size. */
16#define RBS (1024*2) 18#define RBS (1024*2)
17 19
18Bu::Client::Client( Bu::Socket *pSocket ) : 20Bu::Client::Client( Bu::Socket *pSocket, class Bu::ClientLinkFactory *pfLink ) :
19 pSocket( pSocket ), 21 pSocket( pSocket ),
20 pProto( NULL ), 22 pProto( NULL ),
21 nRBOffset( 0 ), 23 nRBOffset( 0 ),
22 bWantsDisconnect( false ) 24 bWantsDisconnect( false ),
25 pfLink( pfLink )
23{ 26{
24} 27}
25 28
@@ -233,3 +236,15 @@ void Bu::Client::close()
233{ 236{
234 pSocket->close(); 237 pSocket->close();
235} 238}
239
240Bu::ClientLink *Bu::Client::getLink()
241{
242 return pfLink->createLink( this );
243}
244
245void Bu::Client::onMessage( const Bu::FString &sMsg )
246{
247 if( pProto )
248 pProto->onMessage( this, sMsg );
249}
250