aboutsummaryrefslogtreecommitdiff
path: root/src/protocolgats.cpp
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2010-08-25 04:57:43 +0000
committerMike Buland <eichlan@xagasoft.com>2010-08-25 04:57:43 +0000
commit2a72923397d866f33221b9d32a3f9653d1a960e7 (patch)
tree26bebaf46e186fa51baad3512ce188ad241cf938 /src/protocolgats.cpp
parentc10a3c3daf273536a7e78c4e6f200e35706cf96f (diff)
downloadlibgats-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.cpp41
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
3Gats::ProtocolGats::ProtocolGats() 4#include <bu/client.h>
5
6Gats::ProtocolGats::ProtocolGats() :
7 pStream( NULL ),
8 pUsedClient( NULL )
4{ 9{
5} 10}
6 11
7Gats::ProtocolGats::~ProtocolGats() 12Gats::ProtocolGats::~ProtocolGats()
8{ 13{
14 delete pStream;
15 pStream = NULL;
16}
17
18void 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
11void Gats::ProtocolGats::onNewData( Bu::Client *pClient ) 27void 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
49void Gats::ProtocolGats::writeObject( Gats::Object *pObj )
50{
51 pStream->writeObject( pObj );
13} 52}
14 53