Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 23, 2009, 6:02:25 PM (16 years ago)
Author:
scheusso
Message:

merged netp5 back to trunk

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/trunk/src/network/ClientConnection.h

    r3084 r3214  
    2626 *
    2727 */
    28 
    29 //
    30 // C++ Interface: ClientConnection
    31 //
    32 // Description:
    33 //
    34 //
    35 // Author:  Oliver Scheuss, (C) 2007
    36 //
    37 // Copyright: See COPYING file that comes with this distribution
    38 //
    39 //
     28 
    4029#ifndef _ClientConnection_H__
    4130#define _ClientConnection_H__
    4231
    4332#include "NetworkPrereqs.h"
    44 
    45 #include <string>
    46 #include "PacketBuffer.h"
    47 
    48 namespace boost { class thread; }
     33#include "Connection.h"
    4934
    5035namespace orxonox
    5136{
    5237
    53     const int NETWORK_PORT = 55556;
    54     const int NETWORK_CLIENT_MAX_CONNECTIONS = 5;
    55     const int NETWORK_CLIENT_WAIT_TIME = 10;
    56     const int NETWORK_CLIENT_CONNECT_TIMEOUT = 3000; // miliseconds
    57     const int NETWORK_CLIENT_CHANNELS = 2;
    58 
    59 
    60   class _NetworkExport ClientConnection{
     38  class _NetworkExport ClientConnection: public Connection{
    6139  public:
    62     ClientConnection(int port, const std::string& address);
    63     ClientConnection(int port, const char* address);
    64     ~ClientConnection();
     40    ClientConnection();
     41    virtual ~ClientConnection();
     42   
     43    void setServerAddress( const std::string& serverAddress );
     44    void setPort( unsigned int port );
     45   
    6546    ENetEvent *getEvent();
    6647    // check wheter the packet queue is empty
    6748    bool queueEmpty();
    6849    // create a new listener thread
    69     bool createConnection();
    70     bool closeConnection();
     50    virtual bool establishConnection();
     51    virtual bool closeConnection();
    7152    // add a packet to queue for the server
    7253    bool addPacket(ENetPacket *packet);
    73     // send out all queued packets
    74     bool sendPackets();
    75     // send out all queued packets and save result in event
    76     //bool sendPackets(ENetEvent *event);
    77     bool waitEstablished(int milisec);
    78     inline bool isConnected(){return established;}
    79     inline bool checkConnection(){ return !quit_ && isConnected(); }
     54    inline bool isConnected(){ return this->established_; }
    8055  private:
    81     ClientConnection(const ClientConnection& copy); // not used
    82     bool processData(ENetEvent *event);
    83     // implementation of the listener
    84     void receiverThread(); //thread2
    85     //packetbuffer
    86     bool establishConnection();
     56    virtual void addClient(ENetEvent* event);
     57    virtual void disconnectPeer(ENetEvent* event);
     58   
    8759    bool disconnectConnection();
    88     PacketBuffer buffer;
    8960    // enet stuff
    90     ENetHost *client;
    91     ENetAddress *serverAddress;
    92     // quit-variable (communication with threads)
    93     bool quit_;
    94     bool established;
     61    ENetAddress *serverAddress_;
     62    bool established_;
    9563    // clientlist
    96     ENetPeer *server;
    97     boost::thread *receiverThread_;
     64    ENetPeer *server_;
    9865};
    99 
    100 
    101 
    102 
    103 
    104 
    10566
    10667
Note: See TracChangeset for help on using the changeset viewer.