The HostRegister is a simple UDP hole-punching server designed to facilitate the exchange of connection details between clients aiming to establish a direct connection.
All commands exchanged between clients and the server are in JSON format.
A PingRequest is a heartbeat sent from a hosting client to the server to maintain the connection. Typically, it is a response to a PingResponse from the server.
A PingResponse is a heartbeat sent from the server to the hosting client to maintain the connection. Upon receiving a PingResponse, the client is expected to respond with a PingRequest.
A HostRegisterRequest is sent by a client when they wish to register themselves as an available host. Upon successful registration, the server will send periodic PingResponses to maintain the connection. If the client fails to respond, they will be dropped as a host, and other clients won't be able to find them anymore. The hosting client should expect a HostLookupResponse from the server whenever a new client tries to request connection information.
A HostRegisterResponse is sent by the server in response to a HostRegisterRequest. It contains a 'host_code', which can be used by a searching client to retrieve connection information via a HostLookupRequest.
A HostLookupRequest is sent by a client attempting to request host connection information using the ID they received from a host. Upon successful lookup, they will receive a HostLookupResponse, and the hosting client will receive a ClientLookupRequest.
A HostLookupResponse is sent from the server to the client. It includes two fields: "success," indicating whether the host lookup was successful, and "host_info," which includes host information needed to establish a connection.
A ClientLookupResponse is sent from the server to the hosting client. It contains a "client_info" field, which includes connection information of the client attempting to connect to the hosting client.