Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/network/ClientConnection.h @ 348

Last change on this file since 348 was 337, checked in by bknecht, 17 years ago

merged merger to FICN branch

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