diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 16:25:22 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2012-11-09 16:25:22 +0000 |
| commit | 74dd68ad611d15abf16a65c36a7cfd3f4492930a (patch) | |
| tree | 843fed9ba6bb03253a01314afc3b1dfbb2dfd26c /src/protocolgats.cpp | |
| parent | d9b407475ae3ebe434b29d9eabdd7d4416e17881 (diff) | |
| download | libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.gz libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.bz2 libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.tar.xz libgats-74dd68ad611d15abf16a65c36a7cfd3f4492930a.zip | |
Made the repo less libbu++-centric.
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 | |||
