Fix #8316: Make sort industries by production and transported with a cargo filter...
[openttd-github.git] / src / network / network_turn.h
blobcc569a977d40bea6723400ac27c895cce58c488e
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 */
8 /** @file network_turn.h Part of the network protocol handling TURN requests. */
10 #ifndef NETWORK_TURN_H
11 #define NETWORK_TURN_H
13 #include "core/tcp_turn.h"
15 /** Class for handling the client side of the TURN connection. */
16 class ClientNetworkTurnSocketHandler : public NetworkTurnSocketHandler {
17 private:
18 std::string token; ///< Token of this connection.
19 uint8 tracking_number; ///< Tracking number of this connection.
20 std::string connection_string; ///< The connection string of the TURN server we are connecting to.
22 protected:
23 bool Receive_TURN_ERROR(Packet *p) override;
24 bool Receive_TURN_CONNECTED(Packet *p) override;
26 public:
27 TCPConnecter *connecter = nullptr; ///< Connecter instance.
28 bool connect_started = false; ///< Whether we started the connection.
30 ClientNetworkTurnSocketHandler(const std::string &token, uint8 tracking_number, const std::string &connection_string) : token(token), tracking_number(tracking_number), connection_string(connection_string) {}
32 NetworkRecvStatus CloseConnection(bool error = true) override;
33 void SendReceive();
35 void Connect();
36 void ConnectFailure();
38 static std::unique_ptr<ClientNetworkTurnSocketHandler> Turn(const std::string &token, uint8 tracking_number, const std::string &ticket, const std::string &connection_string);
41 #endif /* NETWORK_TURN_H */