diff options
author | Mike Buland <eichlan@xagasoft.com> | 2008-02-07 19:01:12 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2008-02-07 19:01:12 +0000 |
commit | 9ab87f39d7fc37e52d742d38b191eed9128d4b5b (patch) | |
tree | 17a00529eda3d9a5a979c05d688f219f7af1631a /src/server.h | |
parent | 5574841cc88412854b2cb94253152b3606803e2a (diff) | |
download | libbu++-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/server.h')
-rw-r--r-- | src/server.h | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/src/server.h b/src/server.h index 02f3546..1ba5fd7 100644 --- a/src/server.h +++ b/src/server.h | |||
@@ -13,6 +13,9 @@ | |||
13 | #include "bu/fstring.h" | 13 | #include "bu/fstring.h" |
14 | #include "bu/list.h" | 14 | #include "bu/list.h" |
15 | 15 | ||
16 | #include "bu/clientlink.h" | ||
17 | #include "bu/clientlinkfactory.h" | ||
18 | |||
16 | namespace Bu | 19 | namespace Bu |
17 | { | 20 | { |
18 | class ServerSocket; | 21 | class ServerSocket; |
@@ -58,6 +61,27 @@ namespace Bu | |||
58 | virtual void onClosedConnection( Client *pClient )=0; | 61 | virtual void onClosedConnection( Client *pClient )=0; |
59 | 62 | ||
60 | private: | 63 | private: |
64 | class SrvClientLink : public Bu::ClientLink | ||
65 | { | ||
66 | public: | ||
67 | SrvClientLink( Bu::Client *pClient ); | ||
68 | virtual ~SrvClientLink(); | ||
69 | |||
70 | virtual void sendMsg( const Bu::FString &sMsg ); | ||
71 | |||
72 | private: | ||
73 | Bu::Client *pClient; | ||
74 | }; | ||
75 | |||
76 | class SrvClientLinkFactory : public Bu::ClientLinkFactory | ||
77 | { | ||
78 | public: | ||
79 | SrvClientLinkFactory(); | ||
80 | virtual ~SrvClientLinkFactory(); | ||
81 | |||
82 | virtual Bu::ClientLink *createLink( Bu::Client *pClient ); | ||
83 | }; | ||
84 | |||
61 | int nTimeoutSec; | 85 | int nTimeoutSec; |
62 | int nTimeoutUSec; | 86 | int nTimeoutUSec; |
63 | fd_set fdActive; | 87 | fd_set fdActive; |