Changeset 415
- Timestamp:
- Dec 5, 2007, 6:23:10 PM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/CMakeLists.txt
r376 r415 6 6 ConnectionManager.cc 7 7 GameStateManager.cc 8 GameStateClient.cc 8 9 PacketBuffer.cc 9 10 PacketDecoder.cc -
code/branches/FICN/src/network/Client.cc
r413 r415 149 149 id=orxonox::ID(std::string(clid->message)); 150 150 if(id!=NULL) 151 id->setNetworkID(clid->cl assid);151 id->setNetworkID(clid->clid); 152 152 return; 153 153 } -
code/branches/FICN/src/network/ConnectionManager.cc
r401 r415 90 90 91 91 bool ConnectionManager::addPacketAll(ENetPacket *packet){ 92 for( int i=0; i<clientVector.size(); i++){92 for(unsigned int i=0; i<clientVector.size(); i++){ 93 93 if(enet_peer_send(&(peerMap.find(clientVector[i])->second), i, packet)!=0) 94 94 return false; … … 158 158 bool disconnected=false; 159 159 ENetEvent event; 160 for( int i=0; i<clientVector.size(); i++){160 for(unsigned int i=0; i<clientVector.size(); i++){ 161 161 enet_peer_disconnect(&(peerMap.find(clientVector[i])->second), 0); 162 162 while( !disconnected && enet_host_service(server, &event, NETWORK_WAIT_TIMEOUT) > 0){ -
code/branches/FICN/src/network/GameStateManager.h
r413 r415 20 20 #include "orxonox/core/IdentifierIncludes.h" 21 21 #include "orxonox/core/Iterator.h" 22 #include "Packet Manager.h"22 #include "PacketTypes.h" 23 23 24 24 namespace network { 25 25 26 /**27 * This struct defines a gamestate:28 * size: total size of the data in *data29 * data: pointer to the data allocated in the memory30 */31 struct GameState{32 int id;33 int size;34 unsigned char *data;35 };36 26 37 /**38 * this struct defines a gamestate:39 * compsize is the size of the compressed data40 * normsize is the size of the uncompressed data41 * data are the gamestates42 */43 struct GameStateCompressed{44 int id;45 int compsize;46 int normsize;47 unsigned char *data;48 };49 27 50 28 /** -
code/branches/FICN/src/network/PacketDecoder.cc
r405 r415 137 137 cid->length = ((classid*)(packet->data))->length; 138 138 cid->id = ((classid *)(packet->data))->id; 139 cid->cl assid = ((classid *)(packet->data))->classid;139 cid->clid = ((classid *)(packet->data))->clid; 140 140 cid->message = (const char *)malloc(cid->length); 141 141 enet_packet_destroy( packet ); … … 193 193 cout << "id of classid: " << cid->id << endl; 194 194 cout << "size of classid: " << cid->length << endl; 195 cout << "ID of classid: " << cid->cl assid <<endl;195 cout << "ID of classid: " << cid->clid <<endl; 196 196 cout << "data of classid: " << cid->message <<endl; 197 197 } -
code/branches/FICN/src/network/PacketGenerator.cc
r405 r415 14 14 #include <cstring> 15 15 16 using namespace std;17 16 using namespace network; 18 17 … … 23 22 ENetPacket* PacketGenerator::acknowledgement( int state, int reliable ) 24 23 { 25 cout << "generating new acknowledgement" <<endl;24 std::cout << "generating new acknowledgement" << std::endl; 26 25 ack* ackreq = new ack; 27 26 ackreq->id = ACK; … … 35 34 ENetPacket* PacketGenerator::mousem( double x, double y, int reliable ) 36 35 { 37 cout << "generating new mouse" <<endl;36 std::cout << "generating new mouse" << std::endl; 38 37 mouse* mousemove = new mouse; 39 38 mousemove->id = MOUSE; … … 48 47 ENetPacket* PacketGenerator::keystrike( char press, int reliable ) 49 48 { 50 cout << "generating new keyboard" <<endl;49 std::cout << "generating new keyboard" << std::endl; 51 50 keyboard* key = new keyboard; 52 51 key->id = KEYBOARD; -
code/branches/FICN/src/network/PacketManager.h
r413 r415 4 4 #include <string> 5 5 #include <enet/enet.h> 6 #include " GameStateManager.h"6 #include "PacketTypes.h" 7 7 8 8 //enum netowk generaly used to set the type ID of a packet 9 9 namespace network{ 10 10 11 enum packet_id { 12 ACK, 13 MOUSE, 14 KEYBOARD, 15 CHAT, 16 GAMESTATE , 17 CLASSID 18 }; 11 12 13 19 14 20 15 /* … … 36 31 ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE ); 37 32 private: 38 //used to set the bytes in the right order39 struct ack {40 int id;41 int a;42 };43 44 struct mouse {45 int id;46 double x;47 double y;48 };49 50 struct keyboard {51 int id;52 char press;53 };54 33 }; 55 34 … … 66 45 //call this function to decode, it calls the right decoding function below 67 46 bool elaborate( ENetPacket* packet, int clientId ); 68 struct classid{ 69 int id; 70 int length; 71 int classid; 72 const char *message; 73 }; 47 74 48 private: 75 struct ack {76 int id;77 int a;78 };79 80 struct mouse {81 int id;82 double x;83 double y;84 };85 86 struct keyboard {87 int id;88 char press;89 };90 //only in this class, not PacketGenerator, used as pattern to put incoming91 //bytes inside92 struct chat {93 int id;94 const char* message;95 };96 49 97 50
Note: See TracChangeset
for help on using the changeset viewer.