aboutsummaryrefslogtreecommitdiff
path: root/c++-libbu++/src/protocolgats.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'c++-libbu++/src/protocolgats.cpp')
-rw-r--r--c++-libbu++/src/protocolgats.cpp63
1 files changed, 35 insertions, 28 deletions
diff --git a/c++-libbu++/src/protocolgats.cpp b/c++-libbu++/src/protocolgats.cpp
index 827eb65..f9d9e04 100644
--- a/c++-libbu++/src/protocolgats.cpp
+++ b/c++-libbu++/src/protocolgats.cpp
@@ -1,3 +1,10 @@
1/*
2 * Copyright (C) 2007-2012 Xagasoft, All rights reserved.
3 *
4 * This file is part of the libgats library and is released under the
5 * terms of the license contained in the file LICENSE.
6 */
7
1#include "gats/protocolgats.h" 8#include "gats/protocolgats.h"
2#include "gats/gatsstream.h" 9#include "gats/gatsstream.h"
3 10
@@ -7,50 +14,50 @@
7using namespace Bu; 14using namespace Bu;
8 15
9Gats::ProtocolGats::ProtocolGats() : 16Gats::ProtocolGats::ProtocolGats() :
10 pStream( NULL ), 17 pStream( NULL ),
11 pUsedClient( NULL ) 18 pUsedClient( NULL )
12{ 19{
13} 20}
14 21
15Gats::ProtocolGats::~ProtocolGats() 22Gats::ProtocolGats::~ProtocolGats()
16{ 23{
17 delete pStream; 24 delete pStream;
18 pStream = NULL; 25 pStream = NULL;
19} 26}
20 27
21void Gats::ProtocolGats::onNewConnection( Bu::Client *pClient ) 28void Gats::ProtocolGats::onNewConnection( Bu::Client *pClient )
22{ 29{
23 if( pStream == NULL ) 30 if( pStream == NULL )
24 { 31 {
25 pStream = new Gats::GatsStream( *pClient ); 32 pStream = new Gats::GatsStream( *pClient );
26 pUsedClient = pClient; 33 pUsedClient = pClient;
27 } 34 }
28} 35}
29 36
30void Gats::ProtocolGats::onNewData( Bu::Client *pClient ) 37void Gats::ProtocolGats::onNewData( Bu::Client *pClient )
31{ 38{
32 if( pStream == NULL ) 39 if( pStream == NULL )
33 { 40 {
34 pStream = new Gats::GatsStream( *pClient ); 41 pStream = new Gats::GatsStream( *pClient );
35 pUsedClient = pClient; 42 pUsedClient = pClient;
36 } 43 }
37 else if( pClient != pUsedClient ) 44 else if( pClient != pUsedClient )
38 { 45 {
39 throw Bu::ExceptionBase("ProtocolGats requires that you maintain a " 46 throw Bu::ExceptionBase("ProtocolGats requires that you maintain a "
40 "1:1 relationship between client and protocol objects."); 47 "1:1 relationship between client and protocol objects.");
41 } 48 }
42 49
43 for(;;) 50 for(;;)
44 { 51 {
45 Gats::Object *pObj = pStream->readObject(); 52 Gats::Object *pObj = pStream->readObject();
46 if( pObj == NULL ) 53 if( pObj == NULL )
47 break; 54 break;
48 onNewObject( pClient, pObj ); 55 onNewObject( pClient, pObj );
49 } 56 }
50} 57}
51 58
52void Gats::ProtocolGats::writeObject( Gats::Object *pObj ) 59void Gats::ProtocolGats::writeObject( Gats::Object *pObj )
53{ 60{
54 pStream->writeObject( pObj ); 61 pStream->writeObject( pObj );
55} 62}
56 63