OpenTTD Source: src/network/core/tcp_turn.h Source File

OpenTTD Source 13.1

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 <http://www.gnu.org/licenses/>.
6 */
7
12 #ifndef NETWORK_CORE_TCP_TURN_H
13 #define NETWORK_CORE_TCP_TURN_H
14
15 #include "os_abstraction.h"
16 #include "tcp.h"
17 #include "packet.h"
18 #include "game_info.h"
19
21 enum PacketTurnType {
22 PACKET_TURN_TURN_ERROR,
23 PACKET_TURN_SERCLI_CONNECT,
24 PACKET_TURN_TURN_CONNECTED,
25 PACKET_TURN_END,
26 };
27
29 class NetworkTurnSocketHandler : public NetworkTCPSocketHandler {
30 protected:
31 bool ReceiveInvalidPacket(PacketTurnType type);
32
41 virtual bool Receive_TURN_ERROR(Packet *p);
42
53 virtual bool Receive_SERCLI_CONNECT(Packet *p);
54
65 virtual bool Receive_TURN_CONNECTED(Packet *p);
66
67 bool HandlePacket(Packet *p);
68 public:
74 NetworkTurnSocketHandler(SOCKET s = INVALID_SOCKET) : NetworkTCPSocketHandler(s) {}
75
76 bool ReceivePackets();
77 };
78
79 #endif /* NETWORK_CORE_TCP_TURN_H */
NetworkTurnSocketHandler::Receive_SERCLI_CONNECT
virtual bool Receive_SERCLI_CONNECT(Packet *p)
Client or servers wants to connect to the TURN server (on request by the Game Coordinator).
Definition: tcp_turn.cpp:70
NetworkTurnSocketHandler::Receive_TURN_ERROR
virtual bool Receive_TURN_ERROR(Packet *p)
TURN server was unable to connect the client or server based on the token.
Definition: tcp_turn.cpp:69
NetworkTurnSocketHandler::Receive_TURN_CONNECTED
virtual bool Receive_TURN_CONNECTED(Packet *p)
TURN server has connected client and server together and will now relay all packets to each other.
Definition: tcp_turn.cpp:71
NetworkTurnSocketHandler
Base socket handler for all TURN TCP sockets.
Definition: tcp_turn.h:29
PacketTurnType
PacketTurnType
Enum with all types of TCP TURN packets.
Definition: tcp_turn.h:21
NetworkTurnSocketHandler::HandlePacket
bool HandlePacket(Packet *p)
Handle the given packet, i.e.
Definition: tcp_turn.cpp:25
Packet
Internal entity of a packet.
Definition: packet.h:44
NetworkTurnSocketHandler::ReceivePackets
bool ReceivePackets()
Receive a packet at TCP level.
Definition: tcp_turn.cpp:44
PACKET_TURN_END
@ PACKET_TURN_END
Must ALWAYS be on the end of this list!! (period)
Definition: tcp_turn.h:25
packet.h
tcp.h
PACKET_TURN_TURN_ERROR
@ PACKET_TURN_TURN_ERROR
TURN server is unable to relay.
Definition: tcp_turn.h:22
PACKET_TURN_SERCLI_CONNECT
@ PACKET_TURN_SERCLI_CONNECT
Client or server is connecting to the TURN server.
Definition: tcp_turn.h:23
game_info.h
NetworkTurnSocketHandler::ReceiveInvalidPacket
bool ReceiveInvalidPacket(PacketTurnType type)
Helper for logging receiving invalid packets.
Definition: tcp_turn.cpp:63
os_abstraction.h
PACKET_TURN_TURN_CONNECTED
@ PACKET_TURN_TURN_CONNECTED
TURN server indicates the socket is now being relayed.
Definition: tcp_turn.h:24
NetworkTurnSocketHandler::NetworkTurnSocketHandler
NetworkTurnSocketHandler(SOCKET s=INVALID_SOCKET)
Create a new cs socket handler for a given cs.
Definition: tcp_turn.h:74
NetworkTCPSocketHandler
Base socket handler for all TCP sockets.
Definition: tcp.h:32