XII Release 0.1.0
Loading...
Searching...
No Matches
xiiFileserveClient Class Reference

Singleton that represents the client side part of a fileserve connection. More...

#include <FileserveClient.h>

Inheritance diagram for xiiFileserveClient:
[legend]

Public Member Functions

xiiRemoteInterfaceGetRemoteInterface () override
 xiiRemoteToolingInterface
 
xiiResult SearchForServerAddress (xiiTime timeout=xiiTime::MakeFromSeconds(5))
 Can be called at startup to go through multiple sources and search for a valid server address.
 
xiiResult WaitForServerInfo (xiiTime timeout=xiiTime::MakeFromSeconds(60.0 *5))
 Waits for a Fileserver application to try to connect to this device and send its own information.
 
xiiResult SaveCurrentConnectionInfoToDisk () const
 Stores the current connection info to a text file in the user data folder.
 
const char * GetServerConnectionAddress ()
 Returns the address through which the Fileserve client tried to connect with the server last.
 
xiiResult EnsureConnected (xiiTime timeout=xiiTime::MakeFromSeconds(-5))
 Can be called to ensure a fileserve connection. Otherwise automatically called when a data directory is mounted.
 
void UpdateClient ()
 Needs to be called regularly to update the network. By default this is automatically called when the global event 'GameApp_UpdatePlugins' is fired, which is done by xiiGameApplication.
 
void AddServerAddressToTry (xiiStringView sAddress)
 Adds an address that should be tried for connecting with the server.
 

Static Public Member Functions

static void DisabledFileserveClient ()
 Allows to disable the file serving functionality. Should be called before mounting data directories.
 

Friends

class xiiDataDirectory::FileserveType
 

Detailed Description

Singleton that represents the client side part of a fileserve connection.

Whether the fileserve plugin will be enabled is controled by xiiFileserveClient::s_bEnableFileserve By default this is on, but if switched off, the fileserve client functionality will be disabled. xiiFileserveClient will also switch its functionality off, if the command line argument "-fs_off" is specified. If a program knows that it always wants to switch file serving off, it should either simply not load the plugin at all, or it can inject that command line argument through xiiCommandLineUtils. This should be done before application startup and especially before any data directories get mounted.

The timeout for connecting to the server can be configured through the command line option "-fs_timeout seconds" The server to connect to can be configured through command line option "-fs_server address". The default address is "localhost:1042".

Member Function Documentation

◆ DisabledFileserveClient()

static void xiiFileserveClient::DisabledFileserveClient ( )
inlinestatic

Allows to disable the file serving functionality. Should be called before mounting data directories.

Also achieved through the command line argument "-fs_off"

◆ EnsureConnected()

xiiResult xiiFileserveClient::EnsureConnected ( xiiTime timeout = xiiTime::MakeFromSeconds(-5))

Can be called to ensure a fileserve connection. Otherwise automatically called when a data directory is mounted.

The timeout defines how long the code will wait for a connection. Positive numbers are a regular timeout. A zero timeout means the application will wait indefinitely. A negative number means to either wait that time, or whatever was specified through the command-line. The timeout can be specified with the command line switch "-fs_timeout X" (in seconds).

Todo
Somehow abstract this away ?

◆ GetRemoteInterface()

xiiRemoteInterface * xiiFileserveClient::GetRemoteInterface ( )
inlineoverridevirtual

xiiRemoteToolingInterface

Returns the network connection interface.

Implements xiiRemoteToolingInterface.

◆ SearchForServerAddress()

xiiResult xiiFileserveClient::SearchForServerAddress ( xiiTime timeout = xiiTime::MakeFromSeconds(5))

Can be called at startup to go through multiple sources and search for a valid server address.

Ie. checks the command line, xiiFileserve.txt in different directories, etc. For every potential IP it checks whether a fileserve connection could be established (e.g. tries to connect and checks whether the server answers). If a valid connection is found, the IP is stored internally and XII_SUCCESS is returned. Call GetServerConnectionAddress() to retrieve the address.

Parameters
timeoutSpecifies the timeout for checking whether a server can be reached.

◆ WaitForServerInfo()

xiiResult xiiFileserveClient::WaitForServerInfo ( xiiTime timeout = xiiTime::MakeFromSeconds(60.0 * 5))

Waits for a Fileserver application to try to connect to this device and send its own information.

This can be used when a device has no proper way to know the IP through which to connect to a Fileserver. Instead the device opens a server connection itself, and waits for the other side to try to connect to it. This typically means that a human has to manually input this device's IP on the host PC into the Fileserve application, thus enabling the exchange of connection information. Once this has happened, this function stores the valid server IP internally and returns with success. A subsequent call to EnsureConnected() should then succeed.

Todo
Abstract this somehow ?

The documentation for this class was generated from the following files: