Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/terrain.old/src/lib/network/udp_server_socket.h @ 9204

Last change on this file since 9204 was 7954, checked in by patrick, 19 years ago

trunk: merged the network branche back to trunk.

File size: 1.6 KB
Line 
1/*!
2 * @file udp_server_socket.h
3 *  waits for incoming connections
4
5 */
6
7#ifndef _UDP_SERVER_SOCKET
8#define _UDP_SERVER_SOCKET
9
10/* include this file, it contains some default definitions */
11#include "netdefs.h"
12
13
14/* include base_object.h since all classes are derived from this one */
15#include "base_object.h"
16#include "server_socket.h"
17#include "udp_socket.h"
18
19#include <list>
20#include <vector>
21
22#define UDP_PACKET_SIZE 10240
23#define MAX_NEW_CONNECTIONS 8
24
25struct NetworkPacket
26{
27  int length;
28  byte * data;
29};
30
31typedef std::list<NetworkPacket> NetworkPacketList;
32
33typedef std::vector<NetworkPacketList> PacketBuffer;
34
35typedef std::vector<IPaddress> UserList;
36
37typedef std::list<UdpSocket*> UdpSocketList;
38
39class UdpServerSocket : public ServerSocket
40{
41  public:
42    UdpServerSocket( int port);
43
44    virtual ~UdpServerSocket();
45
46    virtual bool listen( unsigned int port );
47   
48    virtual NetworkSocket* getNewSocket( void );
49   
50    virtual void close();
51   
52    virtual void update();
53   
54    void removeUserPackets( int userId );
55    void removeUser( int userId );
56    NetworkPacket getPacket( int userId );
57    bool sendPacket( NetworkPacket networkPacket, int userId );
58    int getPacketCount( int childId );
59    void initUser( int childId, IPaddress ip );
60   
61  private:
62    UDPsocket     socket;           //!< will be uses to send/recieve data
63    UDPpacket *   packet;           //!< packet structure to recieve packet
64    PacketBuffer  packetBuffer;     //!< will store recieved packets for UdpSockets
65    UserList      userList;         //!< contains information about clients
66    UdpSocketList newSocketList;    //!< contains new socket
67
68};
69
70#endif
Note: See TracBrowser for help on using the repository browser.