OpenTTD Source 20260109-master-g241b5fcdfe
tcp_content.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef NETWORK_CORE_TCP_CONTENT_H
11#define NETWORK_CORE_TCP_CONTENT_H
12
13#include "os_abstraction.h"
14#include "tcp.h"
15#include "packet.h"
16#include "../../debug.h"
17#include "tcp_content_type.h"
18
21protected:
23
35 virtual bool Receive_CLIENT_INFO_LIST(Packet &p);
36
44 virtual bool Receive_CLIENT_INFO_ID(Packet &p);
45
58 virtual bool Receive_CLIENT_INFO_EXTID(Packet &p);
59
74
91 virtual bool Receive_SERVER_INFO(Packet &p);
92
100 virtual bool Receive_CLIENT_CONTENT(Packet &p);
101
112 virtual bool Receive_SERVER_CONTENT(Packet &p);
113
114 bool HandlePacket(Packet &p);
115public:
121 NetworkContentSocketHandler(SOCKET s = INVALID_SOCKET) :
123 {
124 }
125
128 {
129 /* Virtual functions get called statically in destructors, so make it explicit to remove any confusion. */
130 this->CloseSocket();
131 }
132
133 bool ReceivePackets();
134};
135
137
138#endif /* NETWORK_CORE_TCP_CONTENT_H */
Base socket handler for all Content TCP sockets.
Definition tcp_content.h:20
virtual bool Receive_CLIENT_CONTENT(Packet &p)
Client requesting the actual content: uint16_t count of unique ids uint32_t unique 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,...
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 ...
virtual bool Receive_SERVER_INFO(Packet &p)
Server sending list of content info: uint8_t type (invalid ID == does not exist) uint32_t id uint32_t...
virtual bool Receive_CLIENT_INFO_ID(Packet &p)
Client requesting a list of content info: uint16_t count of ids uint32_t id (count times)
virtual bool Receive_SERVER_CONTENT(Packet &p)
Server sending list of content info: uint32_t unique id uint32_t file size (0 == does not exist) stri...
NetworkContentSocketHandler(SOCKET s=INVALID_SOCKET)
Create a new cs socket handler for a given cs.
bool ReceivePackets()
Receive a packet at TCP level.
virtual bool Receive_CLIENT_INFO_LIST(Packet &p)
Client requesting a list of content info: uint8_t type uint32_t openttd version (or 0xFFFFFFFF if usi...
~NetworkContentSocketHandler() override
On destructing of this class, the socket needs to be closed.
bool ReceiveInvalidPacket(PacketContentType type)
Helper for logging receiving invalid packets.
bool HandlePacket(Packet &p)
Handle the given packet, i.e.
Base socket handler for all TCP sockets.
Definition tcp.h:29
void CloseSocket()
Close the actual socket of the connection.
Definition tcp.cpp:27
Subdirectory
The different kinds of subdirectories OpenTTD uses.
Definition fileio_type.h:88
Includes and/or implementations for the network stuff.
Basic functions to create, fill and read packets.
Internal entity of a packet.
Definition packet.h:41
Basic functions to receive and send TCP packets.
Subdirectory GetContentInfoSubDir(ContentType type)
Helper to get the subdirectory a ContentInfo is located in.
Basic types related to the content on the content server.
ContentType
The values in the enum are important; they are used as database 'keys'.
PacketContentType
Enum with all types of TCP content packets.