diff options
Diffstat (limited to 'src/protocolgats.cpp')
-rw-r--r-- | src/protocolgats.cpp | 56 |
1 files changed, 0 insertions, 56 deletions
diff --git a/src/protocolgats.cpp b/src/protocolgats.cpp deleted file mode 100644 index 827eb65..0000000 --- a/src/protocolgats.cpp +++ /dev/null | |||
@@ -1,56 +0,0 @@ | |||
1 | #include "gats/protocolgats.h" | ||
2 | #include "gats/gatsstream.h" | ||
3 | |||
4 | #include <bu/client.h> | ||
5 | |||
6 | #include <bu/sio.h> | ||
7 | using namespace Bu; | ||
8 | |||
9 | Gats::ProtocolGats::ProtocolGats() : | ||
10 | pStream( NULL ), | ||
11 | pUsedClient( NULL ) | ||
12 | { | ||
13 | } | ||
14 | |||
15 | Gats::ProtocolGats::~ProtocolGats() | ||
16 | { | ||
17 | delete pStream; | ||
18 | pStream = NULL; | ||
19 | } | ||
20 | |||
21 | void Gats::ProtocolGats::onNewConnection( Bu::Client *pClient ) | ||
22 | { | ||
23 | if( pStream == NULL ) | ||
24 | { | ||
25 | pStream = new Gats::GatsStream( *pClient ); | ||
26 | pUsedClient = pClient; | ||
27 | } | ||
28 | } | ||
29 | |||
30 | void Gats::ProtocolGats::onNewData( Bu::Client *pClient ) | ||
31 | { | ||
32 | if( pStream == NULL ) | ||
33 | { | ||
34 | pStream = new Gats::GatsStream( *pClient ); | ||
35 | pUsedClient = pClient; | ||
36 | } | ||
37 | else if( pClient != pUsedClient ) | ||
38 | { | ||
39 | throw Bu::ExceptionBase("ProtocolGats requires that you maintain a " | ||
40 | "1:1 relationship between client and protocol objects."); | ||
41 | } | ||
42 | |||
43 | for(;;) | ||
44 | { | ||
45 | Gats::Object *pObj = pStream->readObject(); | ||
46 | if( pObj == NULL ) | ||
47 | break; | ||
48 | onNewObject( pClient, pObj ); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | void Gats::ProtocolGats::writeObject( Gats::Object *pObj ) | ||
53 | { | ||
54 | pStream->writeObject( pObj ); | ||
55 | } | ||
56 | |||