OpenTTD Source 20261112-master-gbcbec5e63f
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
26
27template <> struct IsEnumPacketType<PacketTurnType> {
28 static constexpr bool value = true;
29};
30
33protected:
35
44 virtual bool ReceiveServerError(Packet &p);
45
56 virtual bool ReceiveClientConnect(Packet &p);
57
68 virtual bool ReceiveServerConnected(Packet &p);
69
70 bool HandlePacket(Packet &p);
71public:
76 NetworkTurnSocketHandler(SOCKET s = INVALID_SOCKET) : NetworkTCPSocketHandler(s) {}
77
78 bool ReceivePackets();
79};
80
81#endif /* NETWORK_CORE_TCP_TURN_H */
NetworkTCPSocketHandler(SOCKET s=INVALID_SOCKET)
Construct a socket handler for a TCP connection.
Definition tcp.h:64
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:66
virtual bool ReceiveServerError(Packet &p)
TURN server was unable to connect the client or server based on the token.
Definition tcp_turn.cpp:65
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:67
bool ReceivePackets()
Receive a packet at TCP level.
Definition tcp_turn.cpp:41
bool ReceiveInvalidPacket(PacketTurnType type)
Helper for logging receiving invalid packets.
Definition tcp_turn.cpp:59
bool HandlePacket(Packet &p)
Handle the given packet, i.e.
Definition tcp_turn.cpp:22
NetworkTurnSocketHandler(SOCKET s=INVALID_SOCKET)
Create a new cs socket handler for a given cs.
Definition tcp_turn.h:76
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:28
Trait to mark an enumeration as a PacketType.
Definition packet.h:32
Basic functions to receive and send TCP packets.
PacketTurnType
Enum with all types of TCP TURN packets.
Definition tcp_turn.h:21
@ ServerError
TURN server is unable to relay.
Definition tcp_turn.h:22
@ ServerConnected
TURN server indicates the socket is now being relayed.
Definition tcp_turn.h:24
@ ClientConnect
Client (or OpenTTD server) is connecting to the TURN server.
Definition tcp_turn.h:23