![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include <fc_config.h>#include <QLocalSocket>#include <QString>#include <QTcpSocket>#include <QUrl>#include "capstr.h"#include "fcintl.h"#include "log.h"#include "fc_version.h"#include "packets.h"#include "attribute.h"#include "chatline_common.h"#include "client_main.h"#include "clinet.h"#include "connectdlg_common.h"#include "dialogs_g.h"#include "governor.h"#include "options.h"#include "packhand.h"#include "qtg_cxxside.h"
Include dependency graph for clinet.cpp:Go to the source code of this file.
Macros | |
| #define | AUTOCONNECT_INTERVAL 500 |
| #define | MAX_AUTOCONNECT_ATTEMPTS 100 |
Functions | |
| static void | close_socket_nomessage (struct connection *pc) |
| Close socket and cleanup. More... | |
| static void | client_conn_close_callback (struct connection *pconn) |
| Client connection close socket callback. More... | |
| static void | error_on_socket () |
| Called when there is an error on the socket. More... | |
| static int | try_to_connect (const QUrl &url, char *errbuf, int errbufsize) |
| Try to connect to a server: More... | |
| int | connect_to_server (const QUrl &url, char *errbuf, int errbufsize) |
| Connect to a freeciv21-server instance – or at least try to. More... | |
| void | make_connection (QIODevice *sock, const QString &username) |
| Called after a connection is completed (e.g., in try_to_connect). More... | |
| void | disconnect_from_server () |
| Get rid of server connection. More... | |
| static int | read_from_connection (struct connection *pc, bool block) |
| A wrapper around read_socket_data() which also handles the case the socket becomes writeable and there is still data which should be sent to the server. More... | |
| void | input_from_server (QIODevice *sock) |
| This function is called when the client received a new input from the server. More... | |
| double | try_to_autoconnect (const QUrl &url) |
| Make an attempt to autoconnect to the server. More... | |
| void | start_autoconnecting_to_server (const QUrl &url) |
| Start trying to autoconnect to freeciv21-server. More... | |
Variables | |
| static bool | autoconnecting = false |
| #define AUTOCONNECT_INTERVAL 500 |
Definition at line 46 of file clinet.cpp.
| #define MAX_AUTOCONNECT_ATTEMPTS 100 |
Definition at line 49 of file clinet.cpp.
|
static |
Client connection close socket callback.
It shouldn't be called directy. Use connection_close() instead.
Definition at line 69 of file clinet.cpp.
Referenced by try_to_connect().
|
static |
Close socket and cleanup.
This one doesn't print a message, so should do so before-hand if necessary.
Definition at line 55 of file clinet.cpp.
Referenced by client_conn_close_callback(), and disconnect_from_server().
| int connect_to_server | ( | const QUrl & | url, |
| char * | errbuf, | ||
| int | errbufsize | ||
| ) |
Connect to a freeciv21-server instance – or at least try to.
On success, return 0; on failure, put an error message in ERRBUF and return -1.
Definition at line 167 of file clinet.cpp.
Referenced by client_start_server(), and page_network::slot_connect().
| void disconnect_from_server | ( | ) |
Get rid of server connection.
This also kills internal server if it's used.
Definition at line 219 of file clinet.cpp.
Referenced by mr_menu::back_to_menu(), client_packet_input(), fc_client::current_page(), popup_quit_dialog(), and fc_client::slot_disconnect().
|
static |
Called when there is an error on the socket.
Definition at line 90 of file clinet.cpp.
Referenced by try_to_connect().
| void input_from_server | ( | QIODevice * | sock | ) |
This function is called when the client received a new input from the server.
Definition at line 297 of file clinet.cpp.
Referenced by fc_client::add_server_source(), and fc_client::server_input().
| void make_connection | ( | QIODevice * | sock, |
| const QString & | username | ||
| ) |
Called after a connection is completed (e.g., in try_to_connect).
Definition at line 188 of file clinet.cpp.
Referenced by try_to_connect().
|
static |
A wrapper around read_socket_data() which also handles the case the socket becomes writeable and there is still data which should be sent to the server.
Returns: -1 : an error occurred - you should close the socket FIXME dropped! -2 : the connection was closed >0 : number of bytes read =0 : no data read, would block
Definition at line 254 of file clinet.cpp.
Referenced by input_from_server().
| void start_autoconnecting_to_server | ( | const QUrl & | url | ) |
Start trying to autoconnect to freeciv21-server.
Calls get_server_address(), then arranges for try_to_autoconnect(), which calls try_to_connect(), to be called roughly every AUTOCONNECT_INTERVAL milliseconds, until success, fatal error or user intervention.
Definition at line 377 of file clinet.cpp.
Referenced by client_state().
| double try_to_autoconnect | ( | const QUrl & | url | ) |
Make an attempt to autoconnect to the server.
It returns number of seconds it should be called again.
Definition at line 339 of file clinet.cpp.
Referenced by real_timer_callback().
|
static |
Try to connect to a server:
Definition at line 111 of file clinet.cpp.
Referenced by connect_to_server(), and try_to_autoconnect().
|
static |
Definition at line 334 of file clinet.cpp.
Referenced by start_autoconnecting_to_server(), and try_to_autoconnect().