Changeset 6007 in orxonox.OLD for branches/network/src/lib/network/network_stream.cc
- Timestamp:
- Dec 10, 2005, 3:45:57 PM (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/network/src/lib/network/network_stream.cc
r5996 r6007 45 45 /* initialize the references */ 46 46 this->type = NET_CLIENT; 47 this->networkSocket = new NetworkSocket();48 47 this->networkProtocol = new NetworkProtocol(); 49 this->synchronizeables = NULL;50 48 this->connectionMonitor = new ConnectionMonitor(); 51 49 } 52 50 53 NetworkStream::NetworkStream(IPaddress& address , NodeType type)51 NetworkStream::NetworkStream(IPaddress& address) 54 52 { 55 this->type = type;53 this->type = NET_CLIENT; 56 54 this->init(); 57 this->networkSocket = new NetworkSocket(address);55 this->networkSockets.push_back(new NetworkSocket(address)); 58 56 this->networkProtocol = new NetworkProtocol(); 59 this->synchronizeables = NULL;60 57 this->connectionMonitor = new ConnectionMonitor(); 61 58 } 62 59 63 60 64 NetworkStream::NetworkStream(unsigned int port , NodeType type)61 NetworkStream::NetworkStream(unsigned int port) 65 62 { 66 this->type = type;63 this->type = NET_SERVER; 67 64 this->init(); 68 this->networkSocket = new NetworkSocket(); 69 // this->networkSocket->listen(port); 65 this->serverSocket = new ServerSocket(port); 70 66 this->networkProtocol = new NetworkProtocol(); 71 this->synchronizeables = NULL;72 67 this->connectionMonitor = new ConnectionMonitor(); 73 }74 75 76 NetworkStream::NetworkStream(IPaddress& address, Synchronizeable& sync, NodeType type)77 : DataStream()78 {79 this->type = type;80 this->init();81 this->networkSocket = new NetworkSocket(address);82 this->networkProtocol = new NetworkProtocol();83 this->synchronizeables = &sync;84 this->connectionMonitor = new ConnectionMonitor();85 this->bActive = true;86 }87 88 89 NetworkStream::NetworkStream(unsigned int port, Synchronizeable& sync, NodeType type)90 : DataStream()91 {92 this->type = type;93 this->init();94 this->networkSocket = new NetworkSocket();95 // this->networkSocket->listen(port);96 this->networkProtocol = new NetworkProtocol();97 this->synchronizeables = &sync;98 this->connectionMonitor = new ConnectionMonitor();99 this->bActive = true;100 68 } 101 69 … … 105 73 /* set the class id for the base object */ 106 74 this->setClassID(CL_NETWORK_STREAM, "NetworkStream"); 107 this->state = NET_REC_HEADER;108 75 this->bActive = false; 76 this->serverSocket = NULL; 109 77 } 110 78 … … 112 80 NetworkStream::~NetworkStream() 113 81 { 82 if ( this->serverSocket ) 83 { 84 serverSocket->close(); 85 delete serverSocket; 86 } 114 87 115 networkSocket->disconnectServer(); 116 117 if( this->networkSocket) 118 delete networkSocket; 88 for (NetworkSocketVector::iterator i = networkSockets.begin(); i!=networkSockets.end(); i++) 89 { 90 if ( *i ) 91 { 92 (*i)->disconnectServer(); 93 delete *i; 94 } 95 } 119 96 120 97 delete connectionMonitor; … … 125 102 void NetworkStream::connectSynchronizeable(Synchronizeable& sync) 126 103 { 127 this->synchronizeables = &sync; 128 if( this->networkSocket != NULL) 104 this->synchronizeables.push_back(&sync); 105 106 if( this->networkSockets.size()>0 ) 129 107 this->bActive = true; 130 108 } … … 133 111 void NetworkStream::processData() 134 112 { 113 #if 0 135 114 int dataLength = 0; 136 115 … … 197 176 } 198 177 199 178 #endif 200 179 }
Note: See TracChangeset
for help on using the changeset viewer.