Changeset 5649 in orxonox.OLD for branches/network/src
- Timestamp:
- Nov 20, 2005, 2:48:33 AM (19 years ago)
- Location:
- branches/network/src
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/data_stream.cc
r5648 r5649 23 23 using namespace std; 24 24 25 26 27 /** 28 * This is the empty construktor 29 */ 30 DataStream::DataStream() 31 { 32 this->setClassID(CL_DATA_STREAM, "DataStream"); 33 } 34 35 36 25 37 /** 26 38 * This is the empty construktor … … 29 41 { 30 42 this->setClassID(CL_DATA_STREAM, "DataStream"); 31 this->sync = &sync;43 this->synchronizeable = &sync; 32 44 33 45 } … … 146 158 } 147 159 148 /**149 * This function moves the data from the downStream object to the upStream object and changes the data if necessary.150 * This function is virtual and therefore needs to be extended by the derived class151 */152 void DataStream::processData()153 {154 155 }156 160 157 161 /** -
branches/network/src/lib/network/data_stream.h
r5648 r5649 60 60 DataStream* downStream; 61 61 NetworkSocket* networkSocket; 62 Synchronizeable* sync ;62 Synchronizeable* synchronizeable; 63 63 64 64 }; -
branches/network/src/lib/network/netdefs.h
r5624 r5649 20 20 21 21 22 typedef enum { 23 NET_SERVER, 24 NET_CLIENT 25 } NodeType; 26 22 27 #endif /* _NETWORK_MANAGER */ -
branches/network/src/lib/network/network_manager.cc
r5648 r5649 130 130 PRINTF(0)("Establish connection...\n"); 131 131 /* creating a new network stream, it will register itself automaticaly to the class list */ 132 NetworkStream* netStream = new NetworkStream(address, sync); 132 NetworkStream* netStream = new NetworkStream(address, sync, NET_CLIENT); 133 } 134 135 /** 136 * creates a new NetworkStream of server type 137 * @param sync: the listener 138 */ 139 NetworkStream& NetworkManager::createServer(Synchronizeable& sync, int port) 140 { 141 PRINTF(0)("Create a new server socket...\n"); 142 /* creating a new network stream, it will register itself automaticaly to the class list */ 143 NetworkStream* netStream = new NetworkStream(sync, port, NET_SERVER); 133 144 } 134 145 … … 152 163 if (this->netStreamList != NULL || (this->netStreamList = ClassList::getList(CL_NETWORK_STREAM)) != NULL) 153 164 { 154 165 tIterator<BaseObject>* iterator = this->netStreamList->getIterator(); 166 NetworkStream* stream = (NetworkStream*)(iterator->firstElement()); 167 while( stream) 168 { 169 stream->processData(); 170 stream = (NetworkStream*)(iterator->nextElement()); 171 } 172 delete iterator; 155 173 } 156 174 -
branches/network/src/lib/network/network_manager.h
r5648 r5649 35 35 NetworkStream& establishConnection(IPaddress& address, Synchronizeable& sync); 36 36 NetworkStream& establishConnection(const char& hostName, const Synchronizeable& sync); 37 NetworkStream& createServer(Synchronizeable& sync, int port); 37 38 void shutdownConnection(); 38 39 -
branches/network/src/lib/network/network_stream.cc
r5648 r5649 27 27 #include "synchronizeable.h" 28 28 #include "list.h" 29 29 #include "debug.h" 30 30 31 31 /* include your own header */ … … 37 37 38 38 39 NetworkStream::NetworkStream() 39 NetworkStream::NetworkStream() 40 : DataStream() 40 41 { 41 42 this->init(); … … 47 48 48 49 49 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync )50 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type) 50 51 : DataStream(sync) 51 52 { 52 53 this->init(); 53 this->networkSocket = new NetworkSocket(); 54 this->networkSocket = new NetworkSocket(/* address, type */); 55 } 56 57 58 NetworkStream::NetworkStream(Synchronizeable& sync, int port, NodeType type) 59 : DataStream(sync) 60 { 61 this->init(); 62 this->networkSocket = new NetworkSocket(/* address, type */); 54 63 } 55 64 … … 64 73 NetworkStream::~NetworkStream() 65 74 { 66 delete networkSocket s;67 delete synchronizeable s;75 delete networkSocket; 76 delete synchronizeable; 68 77 delete connectionMonitor; 69 78 … … 72 81 void NetworkStream::processData() 73 82 { 83 PRINTF(0)("process data\n"); 74 84 byte data[10] ; // obsolete, for debugging only 75 85 byte* test = (byte *)data[0]; // obsolete, for debugging only 76 86 int ret = 0; 77 this->synchronizeable s->writeByteStream(NULL);78 ret = this->networkSocket s->writeBytes(NULL,1);79 test = this->synchronizeable s->readByteStream();80 ret = this->networkSocket s->readBytes(test,1);87 this->synchronizeable->writeByteStream(NULL); 88 ret = this->networkSocket->writeBytes(NULL,1); 89 test = this->synchronizeable->readByteStream(); 90 ret = this->networkSocket->readBytes(test,1); 81 91 } 82 92 -
branches/network/src/lib/network/network_stream.h
r5648 r5649 13 13 class ConnectionMonitor; 14 14 15 class NetworkStream : public virtualDataStream15 class NetworkStream : public DataStream 16 16 { 17 17 18 18 public: 19 19 NetworkStream(); 20 NetworkStream(IPaddress& address, Synchronizeable& sync); 20 NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type); 21 NetworkStream(Synchronizeable& sync, int port, NodeType type); 21 22 22 23 ~NetworkStream(); -
branches/network/src/subprojects/network/Makefile.am
r5619 r5649 20 20 $(MAINSRCDIR)/util/loading/load_param.cc \ 21 21 $(MAINSRCDIR)/lib/util/substring.cc \ 22 $(MAINSRCDIR)/lib/util/helper_functions.cc 22 $(MAINSRCDIR)/lib/util/helper_functions.cc 23 23 24 24 25 -
branches/network/src/subprojects/network/network_unit_test.cc
r5647 r5649 8 8 #include "network_manager.h" 9 9 #include "network_socket.h" 10 #include "network_stream.h" 10 11 #include "synchronizeable.h" 11 12 … … 124 125 Synchronizeable sync; 125 126 127 126 128 /* create the network manager */ 127 129 NetworkManager* nm = new NetworkManager(); … … 130 132 nm->initialize(); 131 133 134 /* create a server stream */ 135 nm->createServer(sync, 9999); 136 132 137 /* esatblish a connection */ 133 138 nm->establishConnection(ip, sync); 139 140 /* synchronize the data 1 time (increment for longer tests) */ 141 for( int i = 0; i < 1; i++) { 142 nm->synchronize(); 143 } 134 144 135 145 /* delete the network manager again */
Note: See TracChangeset
for help on using the changeset viewer.