~ubuntu-branches/ubuntu/raring/simutrans/raring-proposed

« back to all changes in this revision

Viewing changes to dataobj/network_socket_list.h

  • Committer: Package Import Robot
  • Author(s): Ansgar Burchardt
  • Date: 2011-11-03 19:59:02 UTC
  • mfrom: (1.2.7)
  • Revision ID: package-import@ubuntu.com-20111103195902-uopgwf488mfctb75
Tags: 111.0-1
* New upstream release.
* debian/rules: Update get-orig-source target for new upstream release.
* Use xz compression for source and binary packages.
* Use override_* targets to simplify debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
#define _NETWORK_SOCKET_LIST_H_
3
3
 
4
4
#include "network.h"
 
5
#include "network_address.h"
5
6
#include "../tpl/slist_tpl.h"
6
7
#include "../tpl/vector_tpl.h"
 
8
#include <string>
7
9
 
8
10
class network_command_t;
9
11
class packet_t;
18
20
                inactive        = 0, // client disconnected
19
21
                server          = 1, // server socket
20
22
                connected       = 2, // connection established but client does not participate in the game yet
21
 
                playing         = 3  // client actively plays
 
23
                playing         = 3, // client actively plays
 
24
                admin       = 4  // admin connection
22
25
        };
23
26
        uint8 state;
24
27
 
25
28
        SOCKET socket;
26
29
 
27
 
        socket_info_t() : packet(0), send_queue(), state(inactive), socket(INVALID_SOCKET) {}
 
30
        net_address_t address;
 
31
 
 
32
        socket_info_t() : packet(0), send_queue(), state(inactive), socket(INVALID_SOCKET), address() {}
28
33
 
29
34
        /**
30
35
         * marks all information as invalid
47
52
        void process_send_queue();
48
53
 
49
54
        void send_queue_append(packet_t *p);
 
55
 
 
56
        /**
 
57
         * rdwr client information to packet
 
58
         */
 
59
        void rdwr(packet_t *p);
50
60
};
51
61
 
52
62
/**
53
 
 * static class that administrates the list of client / server sockets
 
63
 * static class that administers the list of client / server sockets
54
64
 */
55
65
class socket_list_t {
56
66
private:
88
98
         * server: adds client socket (ie connection to client)
89
99
         * client: adds client socket (ie connection to server)
90
100
         */
91
 
        static void add_client( SOCKET sock );
 
101
        static void add_client( SOCKET sock, uint32 ip = 0 );
92
102
 
93
103
        /**
94
104
         * @ returns true if socket is already in our list
123
133
 
124
134
        static void change_state(uint32 id, uint8 new_state);
125
135
 
 
136
        /**
 
137
         * rdwr client-list information to packet
 
138
         */
 
139
        static void rdwr(packet_t *p, vector_tpl<socket_info_t> *writeto=&list);
 
140
 
126
141
private:
127
142
        static void book_state_change(uint8 state, sint8 incr);
128
143