Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 3, 2007, 12:28:19 AM (17 years ago)
Author:
scheusso
Message:

PacketDecoder:

Extended Class to make inheriting easier…

-added virtual function, that can be implemented by lower classes

Client:

Added some function, changed some things (input, gamestate, connectionhandling)

Server:

same as client

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/FICN/src/network/Server.cc

    r337 r369  
    2121   */
    2222  Server::Server(){
    23 
    24 
     23    connection = ConnectionManager();
     24    gamestates = GameStateManager();
     25    packet_gen = PacketGenerator();
    2526  }
    2627
     
    3031   * @param bindAddress Address to listen on
    3132   */
    32   Server::Server(int port, std::string bindAddress) : connection(port, bindAddress){
    33 
    34 
     33  Server::Server(int port, std::string bindAddress){
     34    connection = ConnectionManager(port, bindAddress);
     35    gamestates = GameStateManager();
     36    packet_gen = PacketGenerator();
    3537  }
    3638
     
    4042   * @param bindAddress Address to listen on
    4143   */
    42   Server::Server(int port, const char *bindAddress) : connection(port, bindAddress){
    43 
    44 
    45 
    46 
     44  Server::Server(int port, const char *bindAddress){
     45    connection = ConnectionManager(port, bindAddress);
     46    gamestates = GameStateManager();
     47    packet_gen = PacketGenerator();
    4748  }
    48 
    49 
    50 
    51 
    52 
     49 
     50  /**
     51   * This function opens the server by creating the listener thread
     52   */
     53  void Server::open(){
     54    connection.createListener();
     55    return;
     56  }
     57 
     58  /**
     59   * This function closes the server
     60   */
     61  void Server::close(){
     62    connection.quitListener();
     63    return;
     64  }
     65 
     66  /**
     67   * This function sends out a message to all clients
     68   * @param msg message
     69   * @return true/false
     70   */
     71  bool Server::sendMSG(std::string msg){
     72    ENetPacket *packet = packet_gen.chatMessage(msg.c_str());
     73    connection.addPacketAll(packet);
     74    return connection.sendPackets();
     75  }
     76  /**
     77   * This function sends out a message to all clients
     78   * @param msg message
     79   * @return true/false
     80   */
     81  bool Server::sendMSG(const char *msg){
     82    ENetPacket *packet = packet_gen.chatMessage(msg);
     83    connection.addPacketAll(packet);
     84    return connection.sendPackets();
     85  }
     86 
     87  void Server::tick(){
     88  }
     89 
    5390}
Note: See TracChangeset for help on using the changeset viewer.