author | rubidium |
Wed, 07 Mar 2007 12:11:48 +0000 | |
changeset 6248 | e4a2ed7e5613 |
parent 6247 | 7d81e3a5d803 |
child 9428 | 1ba05b499957 |
permissions | -rw-r--r-- |
5523
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
1 |
/* $Id$ */ |
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
2 |
|
6121
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5881
diff
changeset
|
3 |
/** |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5881
diff
changeset
|
4 |
* @file core.h Base for all network types (UDP and TCP) |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5881
diff
changeset
|
5 |
*/ |
2aae24b0881f
(svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents:
5881
diff
changeset
|
6 |
|
5523
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
7 |
#ifndef NETWORK_CORE_H |
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
8 |
#define NETWORK_CORE_H |
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
9 |
|
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
10 |
#ifdef ENABLE_NETWORK |
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
11 |
|
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
12 |
#include "os_abstraction.h" |
5870
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
13 |
#include "../../newgrf_config.h" |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
14 |
|
6247 | 15 |
bool NetworkCoreInitialize(); |
16 |
void NetworkCoreShutdown(); |
|
5523
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
17 |
|
5864
a95a2849b0e1
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
rubidium
parents:
5624
diff
changeset
|
18 |
/** Status of a network client; reasons why a client has quit */ |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
19 |
enum NetworkRecvStatus { |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
20 |
NETWORK_RECV_STATUS_OKAY, ///< Everything is okay |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
21 |
NETWORK_RECV_STATUS_DESYNC, ///< A desync did occur |
5872
63eafeb3f393
(svn r8461) -Feature: check for NewGRF compatability before actually downloading the map from a game server when connecting from the command prompt and internal console.
rubidium
parents:
5870
diff
changeset
|
22 |
NETWORK_RECV_STATUS_NEWGRF_MISMATCH, ///< We did not have the required NewGRFs |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
23 |
NETWORK_RECV_STATUS_SAVEGAME, ///< Something went wrong (down)loading the savegame |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
24 |
NETWORK_RECV_STATUS_CONN_LOST, ///< The conection is 'just' lost |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
25 |
NETWORK_RECV_STATUS_MALFORMED_PACKET, ///< We apparently send a malformed packet |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
26 |
NETWORK_RECV_STATUS_SERVER_ERROR, ///< The server told us we made an error |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
27 |
NETWORK_RECV_STATUS_SERVER_FULL, ///< The server is full |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
28 |
NETWORK_RECV_STATUS_SERVER_BANNED, ///< The server has banned us |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
29 |
NETWORK_RECV_STATUS_CLOSE_QUERY, ///< Done quering the server |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
6247
diff
changeset
|
30 |
}; |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
31 |
|
5870
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
32 |
/** Forward declaration due to circular dependencies */ |
5881
9002ecbb05d3
(svn r8479) -Fix (r8459): Silenced VC warning C4099: 'Packet' : type name first seen using 'class' now seen using 'struct'
KUDr
parents:
5872
diff
changeset
|
33 |
struct Packet; |
5870
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
34 |
|
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
35 |
/** |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
36 |
* SocketHandler for all network sockets in OpenTTD. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
37 |
*/ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
38 |
class NetworkSocketHandler { |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
39 |
public: |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
40 |
/* TODO: make socket & has_quit protected once the TCP stuff |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
41 |
*is in a real class too */ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
42 |
bool has_quit; ///< Whether the current client has quit/send a bad packet |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
43 |
SOCKET sock; ///< The socket currently connected to |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
44 |
public: |
5864
a95a2849b0e1
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
rubidium
parents:
5624
diff
changeset
|
45 |
/** Create a new unbound socket */ |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
46 |
NetworkSocketHandler() { this->sock = INVALID_SOCKET; this->has_quit = false; } |
5864
a95a2849b0e1
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
rubidium
parents:
5624
diff
changeset
|
47 |
|
a95a2849b0e1
(svn r8445) -Cleanup: remove some @params from comments as the parameters did not exist anymore and add comments to several variables/functions.
rubidium
parents:
5624
diff
changeset
|
48 |
/** Close the socket when distructing the socket handler */ |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
49 |
virtual ~NetworkSocketHandler() { this->Close(); } |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
50 |
|
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
51 |
/** Really close the socket */ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
52 |
virtual void Close() {} |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
53 |
|
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
54 |
/** |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
55 |
* Close the current connection; for TCP this will be mostly equivalent |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
56 |
* to Close(), but for UDP it just means the packet has to be dropped. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
57 |
* @return new status of the connection. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
58 |
*/ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
59 |
virtual NetworkRecvStatus CloseConnection() { this->has_quit = true; return NETWORK_RECV_STATUS_OKAY; } |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
60 |
|
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
61 |
/** |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
62 |
* Whether this socket is currently bound to a socket. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
63 |
* @return true when the socket is bound, false otherwise |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
64 |
*/ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
65 |
bool IsConnected() { return this->sock != INVALID_SOCKET; } |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
66 |
|
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
67 |
/** |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
68 |
* Whether the current client connected to the socket has quit. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
69 |
* In the case of UDP, for example, once a client quits (send bad |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
70 |
* data), the socket in not closed; only the packet is dropped. |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
71 |
* @return true when the current client has quit, false otherwise |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
72 |
*/ |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
73 |
bool HasClientQuit() { return this->has_quit; } |
5870
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
74 |
|
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
75 |
void Send_GRFIdentifier(Packet *p, const GRFIdentifier *grf); |
5056f5b1d16a
(svn r8459) -Codechange: move (Send|Recv)GRFIdentifier to NetworkSocketHandler, so it can also be used the TCP socket handler.
rubidium
parents:
5864
diff
changeset
|
76 |
void Recv_GRFIdentifier(Packet *p, GRFIdentifier *grf); |
5624
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
77 |
}; |
6afe9d27430a
(svn r8083) -Codechange: make a NetworkSocketHandler as base for all sockets and move a little of NetworkClientState functionality to the NetworkSocketHandler. Move the rest of the NetworkClientState to the new NetworkTCPSocketHandler class/struct, which is not yet implemented in an object oriented manner. The UDP socket handler now extends the NetworkSocketHandler instead of having a reference to a NetworkClientState.
rubidium
parents:
5524
diff
changeset
|
78 |
|
5523
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
79 |
#endif /* ENABLE_NETWORK */ |
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
80 |
|
623a8856e35b
(svn r7829) -Codechange: move the network (core) initialization/shutdown functions into network/core, so the can be reused in the masterserver_updater.
rubidium
parents:
diff
changeset
|
81 |
#endif /* NETWORK_CORE_H */ |