Base socket handler for all Content TCP sockets. More...
#include <tcp_content.h>
Public Member Functions | |
NetworkContentSocketHandler (SOCKET s=INVALID_SOCKET, const NetworkAddress &address=NetworkAddress()) | |
Create a new cs socket handler for a given cs. | |
virtual | ~NetworkContentSocketHandler () |
On destructing of this class, the socket needs to be closed. | |
void | ReceivePackets () |
Receive a packet at TCP level. | |
Protected Member Functions | |
virtual void | Close () |
Really close the socket. | |
bool | ReceiveInvalidPacket (PacketContentType type) |
Helper for logging receiving invalid packets. | |
virtual bool | Receive_CLIENT_INFO_LIST (Packet *p) |
Client requesting a list of content info: byte type uint32 openttd version. | |
virtual bool | Receive_CLIENT_INFO_ID (Packet *p) |
Client requesting a list of content info: uint16 count of ids uint32 id (count times). | |
virtual bool | Receive_CLIENT_INFO_EXTID (Packet *p) |
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs. | |
virtual bool | Receive_CLIENT_INFO_EXTID_MD5 (Packet *p) |
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checsums for base graphics and AIs. | |
virtual bool | Receive_SERVER_INFO (Packet *p) |
Server sending list of content info: byte type (invalid ID == does not exist) uint32 id uint32 file_size string name (max 32 characters) string version (max 16 characters) uint32 unique id uint8 md5sum (16 bytes) uint8 dependency count uint32 unique id of dependency (dependency count times) uint8 tag count string tag (max 32 characters for tag count times). | |
virtual bool | Receive_CLIENT_CONTENT (Packet *p) |
Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times). | |
virtual bool | Receive_SERVER_CONTENT (Packet *p) |
Server sending list of content info: uint32 unique id uint32 file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type. | |
bool | HandlePacket (Packet *p) |
Handle the given packet, i.e. | |
Protected Attributes | |
NetworkAddress | client_addr |
The address we're connected to. |
Base socket handler for all Content TCP sockets.
Definition at line 97 of file tcp_content.h.
NetworkContentSocketHandler::NetworkContentSocketHandler | ( | SOCKET | s = INVALID_SOCKET , |
|
const NetworkAddress & | address = NetworkAddress() | |||
) | [inline] |
Create a new cs socket handler for a given cs.
s | the socket we are connected with | |
address | IP etc. of the client |
Definition at line 197 of file tcp_content.h.
bool NetworkContentSocketHandler::HandlePacket | ( | Packet * | p | ) | [protected] |
Handle the given packet, i.e.
pass it to the right parser receive command.
p | the packet to handle |
Definition at line 110 of file tcp_content.cpp.
References client_addr, DEBUG, NetworkAddress::GetAddressAsString(), NetworkSocketHandler::HasClientQuit(), PACKET_CONTENT_CLIENT_CONTENT, PACKET_CONTENT_CLIENT_INFO_EXTID, PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, PACKET_CONTENT_CLIENT_INFO_ID, PACKET_CONTENT_CLIENT_INFO_LIST, PACKET_CONTENT_END, PACKET_CONTENT_SERVER_CONTENT, PACKET_CONTENT_SERVER_INFO, Receive_CLIENT_CONTENT(), Receive_CLIENT_INFO_EXTID(), Receive_CLIENT_INFO_EXTID_MD5(), Receive_CLIENT_INFO_ID(), Receive_CLIENT_INFO_LIST(), Receive_SERVER_CONTENT(), Receive_SERVER_INFO(), and Packet::Recv_uint8().
Referenced by ReceivePackets().
bool NetworkContentSocketHandler::Receive_CLIENT_CONTENT | ( | Packet * | p | ) | [protected, virtual] |
Client requesting the actual content: uint16 count of unique ids uint32 unique id (count times).
p | The packet that was just received. |
Definition at line 163 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_CONTENT, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID | ( | Packet * | p | ) | [protected, virtual] |
Client requesting a list of content info based on an external 'unique' id; GRF ID for NewGRFS, shortname and for base graphics and AIs.
Scenarios and AI libraries are not supported uint8 count of requests for each request: uint8 type unique id (uint32)
p | The packet that was just received. |
Definition at line 160 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_EXTID, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_EXTID_MD5 | ( | Packet * | p | ) | [protected, virtual] |
Client requesting a list of content info based on an external 'unique' id; GRF ID + MD5 checksum for NewGRFS, shortname and xor-ed MD5 checsums for base graphics and AIs.
Scenarios and AI libraries are not supported uint8 count of requests for each request: uint8 type unique id (uint32) md5 (16 bytes)
p | The packet that was just received. |
Definition at line 161 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_EXTID_MD5, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_ID | ( | Packet * | p | ) | [protected, virtual] |
Client requesting a list of content info: uint16 count of ids uint32 id (count times).
p | The packet that was just received. |
Definition at line 159 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_ID, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_CLIENT_INFO_LIST | ( | Packet * | p | ) | [protected, virtual] |
Client requesting a list of content info: byte type uint32 openttd version.
p | The packet that was just received. |
Definition at line 158 of file tcp_content.cpp.
References PACKET_CONTENT_CLIENT_INFO_LIST, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_SERVER_CONTENT | ( | Packet * | p | ) | [protected, virtual] |
Server sending list of content info: uint32 unique id uint32 file size (0 == does not exist) string file name (max 48 characters) After this initial packet, packets with the actual data are send using the same packet type.
p | The packet that was just received. |
Definition at line 164 of file tcp_content.cpp.
References PACKET_CONTENT_SERVER_CONTENT, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::Receive_SERVER_INFO | ( | Packet * | p | ) | [protected, virtual] |
Server sending list of content info: byte type (invalid ID == does not exist) uint32 id uint32 file_size string name (max 32 characters) string version (max 16 characters) uint32 unique id uint8 md5sum (16 bytes) uint8 dependency count uint32 unique id of dependency (dependency count times) uint8 tag count string tag (max 32 characters for tag count times).
p | The packet that was just received. |
Definition at line 162 of file tcp_content.cpp.
References PACKET_CONTENT_SERVER_INFO, and ReceiveInvalidPacket().
Referenced by HandlePacket().
bool NetworkContentSocketHandler::ReceiveInvalidPacket | ( | PacketContentType | type | ) | [protected] |
Helper for logging receiving invalid packets.
type | The received packet type. |
Definition at line 152 of file tcp_content.cpp.
References client_addr, DEBUG, and NetworkAddress::GetAddressAsString().
Referenced by Receive_CLIENT_CONTENT(), Receive_CLIENT_INFO_EXTID(), Receive_CLIENT_INFO_EXTID_MD5(), Receive_CLIENT_INFO_ID(), Receive_CLIENT_INFO_LIST(), Receive_SERVER_CONTENT(), and Receive_SERVER_INFO().