aboutsummaryrefslogtreecommitdiff
path: root/src/itoserver.h
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/itoserver.h
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/itoserver.h')
-rw-r--r--src/itoserver.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/itoserver.h b/src/itoserver.h
index f11960c..09ed1cd 100644
--- a/src/itoserver.h
+++ b/src/itoserver.h
@@ -17,6 +17,9 @@
17#include "bu/itoqueue.h" 17#include "bu/itoqueue.h"
18#include "bu/set.h" 18#include "bu/set.h"
19 19
20#include "bu/clientlink.h"
21#include "bu/clientlinkfactory.h"
22
20namespace Bu 23namespace Bu
21{ 24{
22 class ServerSocket; 25 class ServerSocket;
@@ -47,6 +50,7 @@ namespace Bu
47 class ItoServer : public Ito 50 class ItoServer : public Ito
48 { 51 {
49 friend class ItoClient; 52 friend class ItoClient;
53 friend class SrvClientLinkFactory;
50 public: 54 public:
51 ItoServer(); 55 ItoServer();
52 virtual ~ItoServer(); 56 virtual ~ItoServer();
@@ -65,8 +69,10 @@ namespace Bu
65 virtual void *run(); 69 virtual void *run();
66 70
67 private: 71 private:
72 class SrvClientLink;
68 class ItoClient : public Ito 73 class ItoClient : public Ito
69 { 74 {
75 friend class Bu::ItoServer::SrvClientLink;
70 public: 76 public:
71 ItoClient( ItoServer &rSrv, int nSocket, int nPort, 77 ItoClient( ItoServer &rSrv, int nSocket, int nPort,
72 int nTimeoutSec, int nTimeoutUSec ); 78 int nTimeoutSec, int nTimeoutUSec );
@@ -74,6 +80,9 @@ namespace Bu
74 80
75 virtual void *run(); 81 virtual void *run();
76 82
83 typedef ItoQueue<Bu::FString *> StringQueue;
84 StringQueue qMsg;
85
77 private: 86 private:
78 ItoServer &rSrv; 87 ItoServer &rSrv;
79 Client *pClient; 88 Client *pClient;
@@ -82,6 +91,31 @@ namespace Bu
82 int iPort; 91 int iPort;
83 int nTimeoutSec; 92 int nTimeoutSec;
84 int nTimeoutUSec; 93 int nTimeoutUSec;
94 ItoMutex imProto;
95 };
96
97 class SrvClientLink : public Bu::ClientLink
98 {
99 public:
100 SrvClientLink( ItoClient *pClient );
101 virtual ~SrvClientLink();
102
103 virtual void sendMsg( const Bu::FString &sMsg );
104
105 private:
106 ItoClient *pClient;
107 };
108
109 class SrvClientLinkFactory : public Bu::ClientLinkFactory
110 {
111 public:
112 SrvClientLinkFactory( ItoServer &rSrv );
113 virtual ~SrvClientLinkFactory();
114
115 virtual Bu::ClientLink *createLink( Bu::Client *pClient );
116
117 private:
118 ItoServer &rSrv;
85 }; 119 };
86 120
87 int nTimeoutSec; 121 int nTimeoutSec;