Base socket handler for all TCP sockets. More...
#include <tcp_game.h>
Public Member Functions | |
NetworkRecvStatus | CloseConnection (bool error=true) |
Functions to help NetworkRecv_Packet/NetworkSend_Packet a bit A socket can make errors. | |
NetworkClientSocket (ClientID client_id=INVALID_CLIENT_ID) | |
void | SetInfo (NetworkClientInfo *info) |
NetworkClientInfo * | GetInfo () const |
const char * | Recv_Command (Packet *p, CommandPacket *cp) |
Receives a command from the network. | |
void | Send_Command (Packet *p, const CommandPacket *cp) |
Sends a command over the network. | |
Data Fields | |
ClientID | client_id |
Client identifier. | |
uint32 | last_frame |
Last frame we have executed. | |
uint32 | last_frame_server |
Last frame the server has executed. | |
byte | lag_test |
Byte used for lag-testing the client. | |
ClientStatus | status |
Status of this client. | |
CommandPacket * | command_queue |
The command-queue awaiting delivery. | |
Private Attributes | |
NetworkClientInfo * | info |
Client info related to this socket. |
Base socket handler for all TCP sockets.
Definition at line 96 of file tcp_game.h.
NetworkRecvStatus NetworkClientSocket::CloseConnection | ( | bool | error = true |
) | [virtual] |
Functions to help NetworkRecv_Packet/NetworkSend_Packet a bit A socket can make errors.
When that happens this handles what to do. For clients: close connection and drop back to main-menu For servers: close connection and that is it
Reimplemented from NetworkTCPSocketHandler.
Definition at line 58 of file tcp_game.cpp.
References _network_server, _networking, _switch_mode, NETWORK_RECV_STATUS_CONN_LOST, and NETWORK_RECV_STATUS_SERVER_ERROR.
const char * NetworkClientSocket::Recv_Command | ( | Packet * | p, | |
CommandPacket * | cp | |||
) |
Receives a command from the network.
p | the packet to read from. | |
cp | the struct to write the data to. |
Definition at line 196 of file network_command.cpp.
References _callback_table, CommandContainer::callback, CommandContainer::cmd, CMD_FLAGS_MASK, CMD_OFFLINE, CommandPacket::company, GetCommandFlags(), IsValidCommand(), lengthof, CommandContainer::p1, CommandContainer::p2, Packet::Recv_string(), CommandContainer::text, and CommandContainer::tile.
Referenced by DEF_SERVER_RECEIVE_COMMAND().
void NetworkClientSocket::Send_Command | ( | Packet * | p, | |
const CommandPacket * | cp | |||
) |
Sends a command over the network.
p | the packet to send it in. | |
cp | the packet to actually send. |
Definition at line 221 of file network_command.cpp.
References _callback_table, CommandContainer::callback, CommandContainer::cmd, CommandPacket::company, lengthof, CommandContainer::p1, CommandContainer::p2, Packet::Send_string(), CommandContainer::text, and CommandContainer::tile.