OpenTTD Source 20260219-master-g698dc9cb08
tcp_turn.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
9
10#ifndef NETWORK_CORE_TCP_TURN_H
11#define NETWORK_CORE_TCP_TURN_H
12
13#include "os_abstraction.h"
14#include "tcp.h"
15#include "packet.h"
16#include "network_game_info.h"
17
27
28template <> struct IsEnumPacketType<PacketTurnType> {
29 static constexpr bool value = true;
30};
31
34protected:
36
45 virtual bool ReceiveServerError(Packet &p);
46
57 virtual bool ReceiveClientConnect(Packet &p);
58
69 virtual bool ReceiveServerConnected(Packet &p);
70
71 bool HandlePacket(Packet &p);
72public:
77 NetworkTurnSocketHandler(SOCKET s = INVALID_SOCKET) : NetworkTCPSocketHandler(s) {}
78
79 bool ReceivePackets();
80};
81
82#endif /* NETWORK_CORE_TCP_TURN_H */
NetworkTCPSocketHandler(SOCKET s=INVALID_SOCKET)
Construct a socket handler for a TCP connection.
Definition tcp.h:65
virtual bool ReceiveClientConnect(Packet &p)
Client (or OpenTTD server) wants to connect to the TURN server (on request by the Game Coordinator).
Definition tcp_turn.cpp:67
virtual bool ReceiveServerError(Packet &p)
TURN server was unable to connect the client or server based on the token.
Definition tcp_turn.cpp:66
virtual bool ReceiveServerConnected(Packet &p)
TURN server has connected client and OpenTTD server together and will now relay all packets to each o...
Definition tcp_turn.cpp:68
bool ReceivePackets()
Receive a packet at TCP level.
Definition tcp_turn.cpp:42
bool ReceiveInvalidPacket(PacketTurnType type)
Helper for logging receiving invalid packets.
Definition tcp_turn.cpp:60
bool HandlePacket(Packet &p)
Handle the given packet, i.e.
Definition tcp_turn.cpp:23
NetworkTurnSocketHandler(SOCKET s=INVALID_SOCKET)
Create a new cs socket handler for a given cs.
Definition tcp_turn.h:77
Convert NetworkGameInfo to Packet and back.
Includes and/or implementations for the network stuff.
Basic functions to create, fill and read packets.
static constexpr bool value
This is an enumeration of a PacketType.
Definition tcp_turn.h:29
Trait to mark an enumeration as a PacketType.
Definition packet.h:24
Basic functions to receive and send TCP packets.
PacketTurnType
Enum with all types of TCP TURN packets.
Definition tcp_turn.h:22
@ ServerError
TURN server is unable to relay.
Definition tcp_turn.h:23
@ ServerConnected
TURN server indicates the socket is now being relayed.
Definition tcp_turn.h:25
@ ClientConnect
Client (or OpenTTD server) is connecting to the TURN server.
Definition tcp_turn.h:24