Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/trunk/src/network/ClientConnection.h @ 811

Last change on this file since 811 was 790, checked in by nicolasc, 17 years ago

merged FICN back into trunk
awaiting release.

File size: 1.6 KB
RevLine 
[217]1//
2// C++ Interface: ClientConnection
3//
[285]4// Description:
[217]5//
6//
7// Author:  Oliver Scheuss, (C) 2007
8//
9// Copyright: See COPYING file that comes with this distribution
10//
11//
[673]12#ifndef _ClientConnection_H__
13#define _ClientConnection_H__
[217]14
15#include <string>
16#include <enet/enet.h>
[777]17
18#include "NetworkPrereqs.h"
[285]19#include "PacketBuffer.h"
[217]20
[777]21namespace network
22{
23
[217]24#define NETWORK_PORT 55556
25#define NETWORK_CLIENT_MAX_CONNECTIONS 5
[658]26#define NETWORK_CLIENT_TIMEOUT 10
[217]27#define NETWORK_SEND_WAIT 5
28#define NETWORK_CLIENT_CHANNELS 2
[285]29
30
[217]31  class ClientConnection{
[777]32  public:
[217]33    ClientConnection(int port, std::string address);
34    ClientConnection(int port, const char* address);
35    ENetPacket *getPacket(ENetAddress &address); // thread1
[369]36    ENetPacket *getPacket(); // thread1
[217]37    // check wheter the packet queue is empty
38    bool queueEmpty();
39    // create a new listener thread
[229]40    bool createConnection();
[217]41    bool closeConnection();
42    // add a packet to queue for the server
43    bool addPacket(ENetPacket *packet);
44    // send out all queued packets
[229]45    bool sendPackets();
46    // send out all queued packets and save result in event
[217]47    bool sendPackets(ENetEvent *event);
48    bool waitEstablished(int milisec);
[777]49  private:
[217]50    bool processData(ENetEvent *event);
51    // implementation of the listener
52    void receiverThread(); //thread2
53    //packetbuffer
54    bool establishConnection();
55    bool disconnectConnection();
56    PacketBuffer buffer;
57    // enet stuff
58    ENetHost *client;
59    ENetAddress serverAddress;
60    // quit-variable (communication with threads)
61    bool quit;
62    bool established;
63    // clientlist
64    ENetPeer *server;
65  };
[285]66
67
68
69
70
71
72
73
[217]74}
75
[673]76#endif /* _ClientConnection_H__ */
Note: See TracBrowser for help on using the repository browser.