Changeset 440
- Timestamp:
- Dec 9, 2007, 3:48:16 PM (17 years ago)
- Location:
- code/branches/FICN/src/network
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/network/CMakeLists.txt
r431 r440 13 13 Server.cc 14 14 Synchronisable.cc 15 dummyserver3.cc 15 16 ) 16 17 -
code/branches/FICN/src/network/Makefile.test
r381 r440 31 31 GameStateManager.o: GameStateManager.cc 32 32 ${CC} -c GameStateManager.cc -g ${INC} 33 ClientInformation.o: ClientInformation.cc 34 ${CC} -c ClientInformation.cc -g ${INC} 33 35 34 36 clean: … … 39 41 client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc 40 42 ${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC} 43 44 chatserver: Server.o ConnectionManager.o PacketGenerator.o PacketDecoder.o PacketBuffer.o ClientInformation.o GameStateManager.o 45 ${CC} dummyserver3.cc Server.o ConnectionManager.o PacketGenerator.o PacketBuffer.o GameStateManager.o ClientInformation.o -o chatserver -lenet -lboost_thread -g ${INC} -
code/branches/FICN/src/network/PacketDecoder.cc
r437 r440 25 25 switch( id ) { 26 26 case ACK: 27 acknowledgement( packet );27 acknowledgement( packet, clientId ); 28 28 return true; 29 29 break; 30 30 case MOUSE: 31 mousem( packet );31 mousem( packet, clientId ); 32 32 return true; 33 33 break; 34 34 case KEYBOARD: 35 keystrike( packet );35 keystrike( packet, clientId ); 36 36 return true; 37 37 break; 38 38 case CHAT: 39 chatMessage( packet );39 chatMessage( packet, clientId ); 40 40 return true; 41 41 break; … … 54 54 //following are the decode functions for the data of the packets 55 55 56 void PacketDecoder::acknowledgement( ENetPacket* packet )56 void PacketDecoder::acknowledgement( ENetPacket* packet, int clientId ) 57 57 { 58 58 ack* a = new ack; … … 65 65 } 66 66 67 void PacketDecoder::mousem( ENetPacket* packet )67 void PacketDecoder::mousem( ENetPacket* packet, int clientId ) 68 68 { 69 69 mouse* mouseMove = new mouse; … … 77 77 } 78 78 79 void PacketDecoder::keystrike( ENetPacket* packet )79 void PacketDecoder::keystrike( ENetPacket* packet, int clientId ) 80 80 { 81 81 keyboard* key = new keyboard; … … 89 89 } 90 90 91 void PacketDecoder::chatMessage( ENetPacket* packet )91 void PacketDecoder::chatMessage( ENetPacket* packet, int clientId ) 92 92 { 93 93 chat* chatting = new chat; … … 104 104 enet_packet_destroy( packet ); 105 105 106 processChat( chatting ); //debug info106 processChat( chatting, clientId ); //debug info 107 107 108 108 } … … 148 148 // now the data processing functions: 149 149 150 void PacketDecoder::processChat( chat *data ){151 printChat(data );150 void PacketDecoder::processChat( chat *data, int clientId){ 151 printChat(data, clientId); 152 152 } 153 153 … … 179 179 } 180 180 181 void PacketDecoder::printChat( chat* data ) 182 { 181 void PacketDecoder::printChat( chat* data, int clientId ) 182 { 183 if(clientId!=CLIENTID_CLIENT) 184 cout << "client: " << clientId << endl; 183 185 cout << "data id: " << data->id << endl; 184 186 cout << "data: " << data->message << endl; -
code/branches/FICN/src/network/PacketManager.h
r437 r440 5 5 #include <enet/enet.h> 6 6 #include "PacketTypes.h" 7 8 #define CLIENTID_CLIENT -1 7 9 8 10 //enum netowk generaly used to set the type ID of a packet … … 27 29 ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE ); 28 30 ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE ); 29 30 31 31 ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE ); 32 ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE ); 33 ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE ); 32 34 private: 33 35 }; … … 50 52 51 53 52 void acknowledgement( ENetPacket* packet);53 void mousem( ENetPacket* packet);54 void keystrike( ENetPacket* packet);55 void chatMessage( ENetPacket* packet);56 57 54 void acknowledgement( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); 55 void mousem( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); 56 void keystrike( ENetPacket* packet, int clientId = CLIENTID_CLIENT ); 57 void chatMessage( ENetPacket* packet, int clientId = CLIENTID_CLIENT); 58 void gstate( ENetPacket* packet ); 59 void clid( ENetPacket *packet); 58 60 59 61 //process data 60 62 //two functions are note yet implemented! 61 63 //virtual void processGamestate(GameState *state); 62 virtual void processChat( chat *data );64 virtual void processChat( chat *data, int clientId); 63 65 virtual void processClassid( classid *cid); 64 66 //virtual void processAck( ack *data); … … 68 70 void printMouse( mouse* data ); 69 71 void printKey( keyboard* data ); 70 void printChat( chat* data );72 void printChat( chat* data, int clientId ); 71 73 void printGamestate( GameStateCompressed *data ); 72 74 void printClassid( classid *cid); 73 75 }; 74 76 } -
code/branches/FICN/src/network/Server.h
r436 r440 38 38 bool sendMSG(const char *msg); 39 39 void tick(); 40 protected: 41 void processQueue(); 42 void updateGamestate(); 40 43 private: 41 44 bool sendGameState(); … … 44 47 PacketGenerator packet_gen; 45 48 46 void processQueue();47 void updateGamestate();48 49 ClientInformation *clients; 49 50 };
Note: See TracChangeset
for help on using the changeset viewer.