diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-08-25 04:57:43 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-08-25 04:57:43 +0000 |
commit | 2a72923397d866f33221b9d32a3f9653d1a960e7 (patch) | |
tree | 26bebaf46e186fa51baad3512ce188ad241cf938 /src/protocolgats.cpp | |
parent | c10a3c3daf273536a7e78c4e6f200e35706cf96f (diff) | |
download | libgats-2a72923397d866f33221b9d32a3f9653d1a960e7.tar.gz libgats-2a72923397d866f33221b9d32a3f9653d1a960e7.tar.bz2 libgats-2a72923397d866f33221b9d32a3f9653d1a960e7.tar.xz libgats-2a72923397d866f33221b9d32a3f9653d1a960e7.zip |
Updates to protocolgats...it should work now.
Diffstat (limited to 'src/protocolgats.cpp')
-rw-r--r-- | src/protocolgats.cpp | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/src/protocolgats.cpp b/src/protocolgats.cpp index fbb25a5..2ef6079 100644 --- a/src/protocolgats.cpp +++ b/src/protocolgats.cpp | |||
@@ -1,14 +1,53 @@ | |||
1 | #include "gats/protocolgats.h" | 1 | #include "gats/protocolgats.h" |
2 | #include "gats/gatsstream.h" | ||
2 | 3 | ||
3 | Gats::ProtocolGats::ProtocolGats() | 4 | #include <bu/client.h> |
5 | |||
6 | Gats::ProtocolGats::ProtocolGats() : | ||
7 | pStream( NULL ), | ||
8 | pUsedClient( NULL ) | ||
4 | { | 9 | { |
5 | } | 10 | } |
6 | 11 | ||
7 | Gats::ProtocolGats::~ProtocolGats() | 12 | Gats::ProtocolGats::~ProtocolGats() |
8 | { | 13 | { |
14 | delete pStream; | ||
15 | pStream = NULL; | ||
16 | } | ||
17 | |||
18 | void Gats::ProtocolGats::onNewConnection( Bu::Client *pClient ) | ||
19 | { | ||
20 | if( pStream == NULL ) | ||
21 | { | ||
22 | pStream = new Gats::GatsStream( *pClient ); | ||
23 | pUsedClient = pClient; | ||
24 | } | ||
9 | } | 25 | } |
10 | 26 | ||
11 | void Gats::ProtocolGats::onNewData( Bu::Client *pClient ) | 27 | void Gats::ProtocolGats::onNewData( Bu::Client *pClient ) |
12 | { | 28 | { |
29 | if( pStream == NULL ) | ||
30 | { | ||
31 | pStream = new Gats::GatsStream( *pClient ); | ||
32 | pUsedClient = pClient; | ||
33 | } | ||
34 | else if( pClient != pUsedClient ) | ||
35 | { | ||
36 | throw Bu::ExceptionBase("ProtocolGats requires that you maintain a " | ||
37 | "1:1 relationship between client and protocol objects."); | ||
38 | } | ||
39 | |||
40 | for(;;) | ||
41 | { | ||
42 | Gats::Object *pObj = pStream->readObject(); | ||
43 | if( pObj == NULL ) | ||
44 | break; | ||
45 | onNewObject( pObj ); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | void Gats::ProtocolGats::writeObject( Gats::Object *pObj ) | ||
50 | { | ||
51 | pStream->writeObject( pObj ); | ||
13 | } | 52 | } |
14 | 53 | ||