aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Buland <eichlan@xagasoft.com>2007-06-12 01:28:27 +0000
committerMike Buland <eichlan@xagasoft.com>2007-06-12 01:28:27 +0000
commit4cb166570a8e2e97216bf6c7aeb99b971ff58ad7 (patch)
treeb8d22af96957666ac761b6ca1b57da1eee2e56a5
parentb6f50f249ba3b18c597531a2d5dbc45f7bfa3eaa (diff)
downloadlibbu++-4cb166570a8e2e97216bf6c7aeb99b971ff58ad7.tar.gz
libbu++-4cb166570a8e2e97216bf6c7aeb99b971ff58ad7.tar.bz2
libbu++-4cb166570a8e2e97216bf6c7aeb99b971ff58ad7.tar.xz
libbu++-4cb166570a8e2e97216bf6c7aeb99b971ff58ad7.zip
Moved out the xml system again. I think that if I am going to do it again,
I'm going to do it over from scratch, that was just painful. Also, started in again on the server system, it's looking pretty good, already got connections working, next up is managing data flow through clients and protocols!
-rw-r--r--src/client.cpp1
-rw-r--r--src/file.cpp4
-rw-r--r--src/old/xmldocument.cpp (renamed from src/xmldocument.cpp)0
-rw-r--r--src/old/xmldocument.h (renamed from src/xmldocument.h)0
-rw-r--r--src/old/xmlnode.cpp (renamed from src/xmlnode.cpp)0
-rw-r--r--src/old/xmlnode.h (renamed from src/xmlnode.h)0
-rw-r--r--src/old/xmlreader.cpp (renamed from src/xmlreader.cpp)0
-rw-r--r--src/old/xmlreader.h (renamed from src/xmlreader.h)0
-rw-r--r--src/old/xmlwriter.cpp (renamed from src/xmlwriter.cpp)0
-rw-r--r--src/old/xmlwriter.h (renamed from src/xmlwriter.h)0
-rw-r--r--src/server.cpp7
-rw-r--r--src/server.h9
-rw-r--r--src/serversocket.cpp5
-rw-r--r--src/serversocket.h1
14 files changed, 22 insertions, 5 deletions
diff --git a/src/client.cpp b/src/client.cpp
index a048ca3..a33cdc3 100644
--- a/src/client.cpp
+++ b/src/client.cpp
@@ -7,3 +7,4 @@ Bu::Client::Client()
7Bu::Client::~Client() 7Bu::Client::~Client()
8{ 8{
9} 9}
10
diff --git a/src/file.cpp b/src/file.cpp
index 14b6e54..2965afa 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -48,8 +48,8 @@ size_t Bu::File::read( void *pBuf, size_t nBytes )
48 48
49 int nAmnt = fread( pBuf, 1, nBytes, fh ); 49 int nAmnt = fread( pBuf, 1, nBytes, fh );
50 50
51 if( nAmnt == 0 ) 51 //if( nAmnt == 0 )
52 throw FileException("End of file."); 52 // throw FileException("End of file.");
53 53
54 return nAmnt; 54 return nAmnt;
55} 55}
diff --git a/src/xmldocument.cpp b/src/old/xmldocument.cpp
index 95b9788..95b9788 100644
--- a/src/xmldocument.cpp
+++ b/src/old/xmldocument.cpp
diff --git a/src/xmldocument.h b/src/old/xmldocument.h
index e0c36eb..e0c36eb 100644
--- a/src/xmldocument.h
+++ b/src/old/xmldocument.h
diff --git a/src/xmlnode.cpp b/src/old/xmlnode.cpp
index 96d5850..96d5850 100644
--- a/src/xmlnode.cpp
+++ b/src/old/xmlnode.cpp
diff --git a/src/xmlnode.h b/src/old/xmlnode.h
index c895cd8..c895cd8 100644
--- a/src/xmlnode.h
+++ b/src/old/xmlnode.h
diff --git a/src/xmlreader.cpp b/src/old/xmlreader.cpp
index 38cad5f..38cad5f 100644
--- a/src/xmlreader.cpp
+++ b/src/old/xmlreader.cpp
diff --git a/src/xmlreader.h b/src/old/xmlreader.h
index 7c85ddb..7c85ddb 100644
--- a/src/xmlreader.h
+++ b/src/old/xmlreader.h
diff --git a/src/xmlwriter.cpp b/src/old/xmlwriter.cpp
index 7dc6ca9..7dc6ca9 100644
--- a/src/xmlwriter.cpp
+++ b/src/old/xmlwriter.cpp
diff --git a/src/xmlwriter.h b/src/old/xmlwriter.h
index 7e3c876..7e3c876 100644
--- a/src/xmlwriter.h
+++ b/src/old/xmlwriter.h
diff --git a/src/server.cpp b/src/server.cpp
index f93238c..abf4c5b 100644
--- a/src/server.cpp
+++ b/src/server.cpp
@@ -53,7 +53,8 @@ void Bu::Server::scan()
53 { 53 {
54 if( hServers.has( j ) ) 54 if( hServers.has( j ) )
55 { 55 {
56 addClient( hServers.get( j )->accept() ); 56 ServerSocket *pSrv = hServers.get( j );
57 addClient( pSrv->accept(), pSrv->getPort() );
57 } 58 }
58 else 59 else
59 { 60 {
@@ -63,11 +64,13 @@ void Bu::Server::scan()
63 } 64 }
64} 65}
65 66
66void Bu::Server::addClient( int nSocket ) 67void Bu::Server::addClient( int nSocket, int nPort )
67{ 68{
68 FD_SET( nSocket, &fdActive ); 69 FD_SET( nSocket, &fdActive );
69 70
70 Client *c = new Client(); 71 Client *c = new Client();
71 hClients.insert( nSocket, c ); 72 hClients.insert( nSocket, c );
73
74 onNewConnection( c, nPort );
72} 75}
73 76
diff --git a/src/server.h b/src/server.h
index 9f4f459..942eb32 100644
--- a/src/server.h
+++ b/src/server.h
@@ -22,6 +22,10 @@ namespace Bu
22 * to the timeout set by setTimeout before returning if there is no data 22 * to the timeout set by setTimeout before returning if there is no data
23 * pending. scan should probably be called in some sort of tight 23 * pending. scan should probably be called in some sort of tight
24 * loop, possibly in it's own thread, or in the main control loop. 24 * loop, possibly in it's own thread, or in the main control loop.
25 *
26 * In order to use a Server you must subclass it and implement the pure
27 * virtual functions. These allow you to receive notification of events
28 * happening within the server itself, and actually makes it useful.
25 */ 29 */
26 class Server 30 class Server
27 { 31 {
@@ -35,7 +39,10 @@ namespace Bu
35 void scan(); 39 void scan();
36 void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 ); 40 void setTimeout( int nTimeoutSec, int nTimeoutUSec=0 );
37 41
38 void addClient( int nSocket ); 42 void addClient( int nSocket, int nPort );
43
44 virtual void onNewConnection( Client *pClient, int nPort )=0;
45 virtual void onClosedConnection( Client *pClient )=0;
39 46
40 private: 47 private:
41 int nTimeoutSec; 48 int nTimeoutSec;
diff --git a/src/serversocket.cpp b/src/serversocket.cpp
index 9c8f743..1424630 100644
--- a/src/serversocket.cpp
+++ b/src/serversocket.cpp
@@ -151,3 +151,8 @@ int Bu::ServerSocket::accept( int nTimeoutSec, int nTimeoutUSec )
151 return -1; 151 return -1;
152} 152}
153 153
154int Bu::ServerSocket::getPort()
155{
156 return nPort;
157}
158
diff --git a/src/serversocket.h b/src/serversocket.h
index d2601e4..cb86078 100644
--- a/src/serversocket.h
+++ b/src/serversocket.h
@@ -25,6 +25,7 @@ namespace Bu
25 25
26 int accept( int nTimeoutSec=0, int nTimeoutUSec=0 ); 26 int accept( int nTimeoutSec=0, int nTimeoutUSec=0 );
27 int getSocket(); 27 int getSocket();
28 int getPort();
28 29
29 private: 30 private:
30 void startServer( struct sockaddr_in &name, int nPoolSize ); 31 void startServer( struct sockaddr_in &name, int nPoolSize );