Freeciv21
Develop your civilization from humble roots to a global empire
servers.h File Reference
#include <QNetworkDatagram>
#include <QUdpSocket>
#include "speclist.h"
+ Include dependency graph for servers.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  fcUdpScan
 
struct  str_players
 
struct  server
 

Macros

#define SERVER_LAN_PORT   4555
 
#define SERVER_LAN_TTL   1
 
#define SERVER_LAN_VERSION   2
 
#define SPECLIST_TAG   server
 
#define SPECLIST_TYPE   struct server
 
#define server_list_iterate(serverlist, pserver)    TYPED_LIST_ITERATE(struct server, serverlist, pserver)
 
#define server_list_iterate_end   LIST_ITERATE_END
 

Typedefs

typedef void(* ServerScanErrorFunc) (struct server_scan *scan, const char *message)
 

Enumerations

enum  server_scan_status {
  SCAN_STATUS_ERROR = 0 , SCAN_STATUS_WAITING , SCAN_STATUS_PARTIAL , SCAN_STATUS_DONE ,
  SCAN_STATUS_ABORT
}
 
enum  server_scan_type { SERVER_SCAN_LOCAL , SERVER_SCAN_GLOBAL , SERVER_SCAN_LAST }
 

Functions

struct server_scanserver_scan_begin (enum server_scan_type type, ServerScanErrorFunc error_func)
 Creates a new server scan and returns it, or nullptr if impossible. More...
 
enum server_scan_type server_scan_get_type (const struct server_scan *scan)
 A simple query function to determine the type of a server scan (previously allocated in server_scan_begin). More...
 
enum server_scan_status server_scan_poll (struct server_scan *scan)
 A function to query servers of the server scan. More...
 
struct server_list * server_scan_get_list (struct server_scan *scan)
 Returns the srv_list currently held by the scan (may be nullptr). More...
 
void server_scan_finish (struct server_scan *scan)
 Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin(). More...
 

Macro Definition Documentation

◆ SERVER_LAN_PORT

#define SERVER_LAN_PORT   4555

Definition at line 17 of file servers.h.

◆ SERVER_LAN_TTL

#define SERVER_LAN_TTL   1

Definition at line 18 of file servers.h.

◆ SERVER_LAN_VERSION

#define SERVER_LAN_VERSION   2

Definition at line 19 of file servers.h.

◆ server_list_iterate

#define server_list_iterate (   serverlist,
  pserver 
)     TYPED_LIST_ITERATE(struct server, serverlist, pserver)

Definition at line 73 of file servers.h.

◆ server_list_iterate_end

#define server_list_iterate_end   LIST_ITERATE_END

Definition at line 75 of file servers.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   server

Definition at line 69 of file servers.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct server

Definition at line 70 of file servers.h.

Typedef Documentation

◆ ServerScanErrorFunc

typedef void(* ServerScanErrorFunc) (struct server_scan *scan, const char *message)

Definition at line 85 of file servers.h.

Enumeration Type Documentation

◆ server_scan_status

Enumerator
SCAN_STATUS_ERROR 
SCAN_STATUS_WAITING 
SCAN_STATUS_PARTIAL 
SCAN_STATUS_DONE 
SCAN_STATUS_ABORT 

Definition at line 21 of file servers.h.

◆ server_scan_type

Enumerator
SERVER_SCAN_LOCAL 
SERVER_SCAN_GLOBAL 
SERVER_SCAN_LAST 

Definition at line 79 of file servers.h.

Function Documentation

◆ server_scan_begin()

struct server_scan* server_scan_begin ( enum server_scan_type  type,
ServerScanErrorFunc  error_func 
)

Creates a new server scan and returns it, or nullptr if impossible.

Depending on 'type' the scan will look for either local or internet games.

error_func provides a callback to be used in case of error; this callback probably should call server_scan_finish.

NB: You must call server_scan_finish() when you are done with the scan to free the memory and resources allocated by it.

Definition at line 518 of file servers.cpp.

Referenced by page_network::update_network_lists().

◆ server_scan_finish()

void server_scan_finish ( struct server_scan scan)

Closes the socket listening on the scan, frees the list of servers, and frees the memory allocated for 'scan' by server_scan_begin().

Definition at line 607 of file servers.cpp.

Referenced by page_network::destroy_server_scans().

◆ server_scan_get_list()

struct server_list* server_scan_get_list ( struct server_scan scan)

Returns the srv_list currently held by the scan (may be nullptr).

Definition at line 594 of file servers.cpp.

Referenced by page_network::check_server_scan(), and page_network::slot_selection_changed().

◆ server_scan_get_type()

enum server_scan_type server_scan_get_type ( const struct server_scan scan)

A simple query function to determine the type of a server scan (previously allocated in server_scan_begin).

Definition at line 518 of file servers.cpp.

Referenced by page_network::check_server_scan().

◆ server_scan_poll()

enum server_scan_status server_scan_poll ( struct server_scan scan)

A function to query servers of the server scan.

This will check any pending network data and update the server list.

The return value indicates the status of the server scan: SCAN_STATUS_ERROR - The scan failed and should be aborted. SCAN_STATUS_WAITING - The scan is in progress (continue polling). SCAN_STATUS_PARTIAL - The scan received some data, with more expected. Get the servers with server_scan_get_list(), and continue polling. SCAN_STATUS_DONE - The scan received all data it expected to receive. Get the servers with server_scan_get_list(), and stop calling this function. SCAN_STATUS_ABORT - The scan has been aborted

Definition at line 518 of file servers.cpp.

Referenced by page_network::check_server_scan().