|
OpenTTD Source
14.0-beta1
|
Go to the documentation of this file.
10 #include "../stdafx.h"
11 #include "core/network_game_info.h"
16 #include "table/strings.h"
18 #include "../safeguards.h"
25 assert(this->
sock != INVALID_SOCKET);
44 std::chrono::steady_clock::duration lag = std::chrono::steady_clock::now() - this->
last_packet;
47 if (lag > std::chrono::seconds(5)) {
84 Debug(net, 9,
"Query::SendGameInfo()");
92 Debug(net, 9,
"Query::Receive_SERVER_FULL()");
105 Debug(net, 9,
"Query::Receive_SERVER_BANNED()");
118 Debug(net, 9,
"Query::Receive_SERVER_GAME_INFO()");
125 DeserializeNetworkGameInfo(p, &item->
info);
127 CheckGameCompatibility(item->
info);
141 Debug(net, 9,
"Query::Receive_SERVER_ERROR(): error={}", error);
145 if (error == NETWORK_ERROR_NOT_EXPECTED) {
167 if (!(*it)->Receive()) {
169 }
else if (!(*it)->CheckConnection()) {
NetworkRecvStatus ReceivePackets()
Do the actual receiving of packets.
void ClearGRFConfigList(GRFConfig **config)
Clear a GRF Config list, freeing all nodes.
std::chrono::steady_clock::time_point last_packet
Time we received the last frame.
NetworkRecvStatus Receive_SERVER_FULL(Packet *p) override
Notification that the server is full.
void Send()
Send the packets of this socket handler.
SOCKET sock
The socket currently connected to.
bool Receive()
Check whether we received/can send some data from/to the server and when that's the case handle it ap...
void UpdateNetworkGameWindow()
Update the network new window because a new server is found on the network.
NetworkGameList * NetworkGameListAddItem(const std::string &connection_string)
Add a new item to the linked gamelist.
static std::vector< std::unique_ptr< QueryNetworkGameSocketHandler > > queries
Pending queries.
#define Debug(category, level, format_string,...)
Ouptut a line of debugging information.
bool CheckConnection()
Check the connection's state, i.e.
@ NGLS_TOO_OLD
Server is too old to query.
NetworkRecvStatus CloseConnection(NetworkRecvStatus status) override
Close the network connection due to the given status.
@ PACKET_CLIENT_GAME_INFO
Request information about the server.
@ NETWORK_RECV_STATUS_CLOSE_QUERY
Done querying the server.
virtual void SendPacket(Packet *packet)
This function puts the packet in the send-queue and it is send as soon as possible.
Internal entity of a packet.
SendPacketsState SendPackets(bool closing_down=false)
Sends all the buffered packets out for this client.
bool CanSendReceive()
Check whether this socket can send or receive something.
NetworkRecvStatus Receive_SERVER_GAME_INFO(Packet *p) override
Sends information about the game.
NetworkRecvStatus Receive_SERVER_ERROR(Packet *p) override
The client made an error: uint8_t Error code caused (see NetworkErrorCode).
NetworkRecvStatus
Status of a network client; reasons why a client has quit.
@ NGLS_BANNED
You are banned from this server.
@ NGLS_ONLINE
Server is online.
Structure with information shown in the game list (GUI)
@ NGLS_OFFLINE
Server is offline (or cannot be queried).
@ NETWORK_RECV_STATUS_CONNECTION_LOST
The connection is lost unexpectedly.
static void SendReceive()
Check if any query needs to send or receive.
@ NETWORK_RECV_STATUS_OKAY
Everything is okay.
NetworkRecvStatus SendGameInfo()
Query the server for server information.
bool refreshing
Whether this server is being queried.
NetworkGameInfo info
The game information of this server.
std::string connection_string
Address we are connected to.
@ NGLS_FULL
Server is full and cannot be queried.
GRFConfig * grfconfig
List of NewGRF files used.
NetworkErrorCode
The error codes we send around in the protocols.
uint8_t Recv_uint8()
Read a 8 bits integer from the packet.
NetworkRecvStatus Receive_SERVER_BANNED(Packet *p) override
Notification that the client trying to join is banned.
NetworkGameListStatus status
Stats of the server.