|
OpenTTD Source
13.2.1
|
Class for handling the client side of the STUN connection. More...
#include <network_stun.h>
Public Member Functions | |
| NetworkRecvStatus | CloseConnection (bool error=true) override |
| This will put this socket handler in a close state. More... | |
| void | SendReceive () |
| Check whether we received/can send some data from/to the STUN server and when that's the case handle it appropriately. | |
| void | Connect (const std::string &token, uint8 family) |
| Connect to the STUN server over either IPv4 or IPv6. More... | |
Public Member Functions inherited from NetworkStunSocketHandler | |
| NetworkStunSocketHandler (SOCKET s=INVALID_SOCKET) | |
| Create a new cs socket handler for a given cs. More... | |
Public Member Functions inherited from NetworkTCPSocketHandler | |
| bool | IsConnected () const |
| Whether this socket is currently bound to a socket. More... | |
| void | CloseSocket () |
| Close the actual socket of the connection. More... | |
| virtual void | SendPacket (Packet *packet) |
| This function puts the packet in the send-queue and it is send as soon as possible. More... | |
| SendPacketsState | SendPackets (bool closing_down=false) |
| Sends all the buffered packets out for this client. More... | |
| virtual Packet * | ReceivePacket () |
| Receives a packet for the given client. More... | |
| bool | CanSendReceive () |
| Check whether this socket can send or receive something. More... | |
| bool | HasSendQueue () |
| Whether there is something pending in the send queue. More... | |
| NetworkTCPSocketHandler (SOCKET s=INVALID_SOCKET) | |
| Construct a socket handler for a TCP connection. More... | |
Public Member Functions inherited from NetworkSocketHandler | |
| NetworkSocketHandler () | |
| Create a new unbound socket. | |
| virtual | ~NetworkSocketHandler () |
| Close the socket when destructing the socket handler. | |
| void | MarkClosed () |
| Mark the connection as closed. More... | |
| bool | HasClientQuit () const |
| Whether the current client connected to the socket has quit. More... | |
| void | Reopen () |
| Reopen the socket so we can send/receive stuff again. | |
Static Public Member Functions | |
| static std::unique_ptr< ClientNetworkStunSocketHandler > | Stun (const std::string &token, uint8 family) |
| Send a STUN packet to the STUN server. More... | |
Data Fields | |
| TCPConnecter * | connecter = nullptr |
| Connecter instance. | |
| NetworkAddress | local_addr |
| Local addresses of the socket. | |
Data Fields inherited from NetworkTCPSocketHandler | |
| SOCKET | sock |
| The socket currently connected to. | |
| bool | writable |
| Can we write to this socket? | |
Private Attributes | |
| std::string | token |
| Token of this STUN handler. | |
| uint8 | family = AF_UNSPEC |
| Family of this STUN handler. | |
| bool | sent_result = false |
| Did we sent the result of the STUN connection? | |
Additional Inherited Members | |
Protected Member Functions inherited from NetworkStunSocketHandler | |
| bool | ReceiveInvalidPacket (PacketStunType type) |
| Helper for logging receiving invalid packets. More... | |
| virtual bool | Receive_SERCLI_STUN (Packet *p) |
| Send a STUN request to the STUN server letting the Game Coordinator know what our actually public IP:port is. More... | |
Class for handling the client side of the STUN connection.
Definition at line 16 of file network_stun.h.
|
overridevirtual |
This will put this socket handler in a close state.
It will not actually close the OS socket; use CloseSocket for this.
| error | Whether we quit under an error condition or not. |
Reimplemented from NetworkTCPSocketHandler.
Definition at line 99 of file network_stun.cpp.
References NetworkTCPSocketHandler::CloseConnection(), connecter, error(), TCPConnecter::Kill(), and NETWORK_RECV_STATUS_OKAY.
| void ClientNetworkStunSocketHandler::Connect | ( | const std::string & | token, |
| uint8 | family | ||
| ) |
Connect to the STUN server over either IPv4 or IPv6.
| token | The token as received from the Game Coordinator. |
| family | What IP family to use. |
Definition at line 69 of file network_stun.cpp.
References connecter, family, NetworkStunConnectionString(), and token.
|
static |
Send a STUN packet to the STUN server.
| token | The token as received from the Game Coordinator. |
| family | What IP family this STUN request is for. |
Definition at line 83 of file network_stun.cpp.
References family, NETWORK_COORDINATOR_VERSION, PACKET_STUN_SERCLI_STUN, Packet::Send_string(), Packet::Send_uint8(), and token.
Referenced by ClientNetworkCoordinatorSocketHandler::Receive_GC_STUN_REQUEST().