Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

Last change on this file since 417 was 369, checked in by scheusso, 17 years ago

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 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    ENetPacket *getPacket(); // thread1
41    // check wheter the packet queue is empty
42    bool queueEmpty();
43    // create a new listener thread
44    bool createConnection();
45    bool closeConnection();
46    // add a packet to queue for the server
47    bool addPacket(ENetPacket *packet);
48    // send out all queued packets
49    bool sendPackets();
50    // send out all queued packets and save result in event
51    bool sendPackets(ENetEvent *event);
52    bool waitEstablished(int milisec);
53    private:
54    bool processData(ENetEvent *event);
55    // implementation of the listener
56    void receiverThread(); //thread2
57    //packetbuffer
58    bool establishConnection();
59    bool disconnectConnection();
60    PacketBuffer buffer;
61    // enet stuff
62    ENetHost *client;
63    ENetAddress serverAddress;
64    // quit-variable (communication with threads)
65    bool quit;
66    bool established;
67    // clientlist
68    ENetPeer *server;
69  };
70
71
72
73
74
75
76
77
78}
79
80#endif
Note: See TracBrowser for help on using the repository browser.