Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 440


Ignore:
Timestamp:
Dec 9, 2007, 3:48:16 PM (17 years ago)
Author:
scheusso
Message:

added dummyserver3.cc (implements a chatserver, including main)

Location:
code/branches/FICN/src/network
Files:
1 added
5 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/CMakeLists.txt

    r431 r440  
    1313  Server.cc
    1414  Synchronisable.cc
     15  dummyserver3.cc
    1516)
    1617
  • code/branches/FICN/src/network/Makefile.test

    r381 r440  
    3131GameStateManager.o: GameStateManager.cc
    3232        ${CC} -c GameStateManager.cc -g ${INC}
     33ClientInformation.o: ClientInformation.cc
     34        ${CC} -c ClientInformation.cc -g ${INC}
    3335
    3436clean:
     
    3941client: PacketGenerator.o ClientConnection.o PacketBuffer.o dummyclient2.cc
    4042        ${CC} dummyclient2.cc PacketGenerator.o PacketBuffer.o ClientConnection.o -o client -lenet -lboost_thread -g ${INC}
     43
     44chatserver: 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  
    2525        switch( id ) {
    2626        case ACK:
    27                 acknowledgement( packet );
     27                acknowledgement( packet, clientId );
    2828                return true;
    2929                break;
    3030        case MOUSE:
    31                 mousem( packet );
     31                mousem( packet, clientId );
    3232                return true;
    3333                break;
    3434        case KEYBOARD:
    35                 keystrike( packet );
     35                keystrike( packet, clientId );
    3636                return true;
    3737                break;
    3838        case CHAT:
    39                 chatMessage( packet );
     39                chatMessage( packet, clientId );
    4040                return true;
    4141                break;
     
    5454//following are the decode functions for the data of the packets
    5555
    56 void PacketDecoder::acknowledgement( ENetPacket* packet )
     56void PacketDecoder::acknowledgement( ENetPacket* packet, int clientId )
    5757{
    5858        ack* a = new ack;
     
    6565}
    6666
    67 void PacketDecoder::mousem( ENetPacket* packet )
     67void PacketDecoder::mousem( ENetPacket* packet, int clientId )
    6868{
    6969        mouse* mouseMove = new mouse;
     
    7777}
    7878
    79 void PacketDecoder::keystrike( ENetPacket* packet )
     79void PacketDecoder::keystrike( ENetPacket* packet, int clientId )
    8080{
    8181        keyboard* key = new keyboard;
     
    8989}
    9090
    91 void PacketDecoder::chatMessage( ENetPacket* packet )
     91void PacketDecoder::chatMessage( ENetPacket* packet, int clientId )
    9292{
    9393        chat* chatting = new chat;
     
    104104        enet_packet_destroy( packet );
    105105       
    106         processChat( chatting ); //debug info
     106        processChat( chatting, clientId ); //debug info
    107107       
    108108}
     
    148148// now the data processing functions:
    149149
    150 void PacketDecoder::processChat( chat *data){
    151   printChat(data);
     150void PacketDecoder::processChat( chat *data, int clientId){
     151  printChat(data, clientId);
    152152}
    153153
     
    179179}
    180180
    181 void PacketDecoder::printChat( chat* data )
    182 {
     181void PacketDecoder::printChat( chat* data, int clientId )
     182{
     183  if(clientId!=CLIENTID_CLIENT)
     184    cout << "client: " << clientId << endl;
    183185        cout << "data id: " << data->id << endl;
    184186        cout << "data:    " << data->message << endl;
  • code/branches/FICN/src/network/PacketManager.h

    r437 r440  
    55#include <enet/enet.h>
    66#include "PacketTypes.h"
     7
     8#define CLIENTID_CLIENT -1
    79
    810//enum netowk generaly used to set the type ID of a packet
     
    2729        ENetPacket* mousem( double x, double y, int reliable = ENET_PACKET_FLAG_RELIABLE );
    2830        ENetPacket* keystrike( char press, int reliable = ENET_PACKET_FLAG_RELIABLE );
    29     ENetPacket* chatMessage( const char* message, int reliable = ENET_PACKET_FLAG_RELIABLE );
    30     ENetPacket* gstate( GameStateCompressed *states, int reliable = ENET_PACKET_FLAG_RELIABLE );
    31     ENetPacket* clid( int classid, std::string classname, int reliable = ENET_PACKET_FLAG_RELIABLE );
     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 );
    3234private:
    3335};
     
    5052       
    5153       
    52     void acknowledgement( ENetPacket* packet );
    53     void mousem( ENetPacket* packet );
    54     void keystrike( ENetPacket* packet );
    55     void chatMessage( ENetPacket* packet );
    56     void gstate( ENetPacket* packet );
    57     void clid( ENetPacket *packet);
     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);
    5860       
    5961  //process data
    6062  //two functions are note yet implemented!
    6163  //virtual void processGamestate(GameState *state);
    62   virtual void processChat( chat *data);
     64  virtual void processChat( chat *data, int clientId);
    6365  virtual void processClassid( classid *cid);
    6466  //virtual void processAck( ack *data);
     
    6870        void printMouse( mouse* data );
    6971        void printKey( keyboard* data );
    70         void printChat( chat* data );
     72        void printChat( chat* data, int clientId );
    7173        void printGamestate( GameStateCompressed *data );
    72     void printClassid( classid *cid);
     74  void printClassid( classid *cid);
    7375};
    7476}
  • code/branches/FICN/src/network/Server.h

    r436 r440  
    3838    bool sendMSG(const char *msg);
    3939    void tick();
     40    protected:
     41    void processQueue();
     42    void updateGamestate();
    4043    private:
    4144    bool sendGameState();
     
    4447    PacketGenerator packet_gen;
    4548   
    46     void processQueue();
    47     void updateGamestate();
    4849    ClientInformation *clients;
    4950  };
Note: See TracChangeset for help on using the changeset viewer.