ezEngine  Release 25.03
ezFileserveClient Class Reference

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

#include <FileserveClient.h>

Inheritance diagram for ezFileserveClient:

Public Member Functions

ezRemoteInterfaceGetRemoteInterface () override
 ezRemoteToolingInterface More...
 
ezResult SearchForServerAddress (ezTime timeout=ezTime::MakeFromSeconds(5))
 Can be called at startup to go through multiple sources and search for a valid server address. More...
 
ezResult WaitForServerInfo (ezTime timeout=ezTime::MakeFromSeconds(60.0 *5))
 Waits for a Fileserver application to try to connect to this device and send its own information. More...
 
ezResult 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.
 
ezResult EnsureConnected (ezTime timeout=ezTime::MakeFromSeconds(-5))
 Can be called to ensure a fileserve connection. Otherwise automatically called when a data directory is mounted. More...
 
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 ezGameApplication.
 
void AddServerAddressToTry (ezStringView 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. More...
 

Friends

class ezDataDirectory::FileserveType
 

Detailed Description

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

Whether the fileserve plugin will be enabled is controled by ezFileserveClient::s_bEnableFileserve By default this is on, but if switched off, the fileserve client functionality will be disabled. ezFileserveClient 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 ezCommandLineUtils. 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 ezFileserveClient::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()

ezResult ezFileserveClient::EnsureConnected ( ezTime  timeout = ezTime::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()

ezRemoteInterface* ezFileserveClient::GetRemoteInterface ( )
inlineoverridevirtual

ezRemoteToolingInterface

Returns the network connection interface.

Implements ezRemoteToolingInterface.

◆ SearchForServerAddress()

ezResult ezFileserveClient::SearchForServerAddress ( ezTime  timeout = ezTime::MakeFromSeconds(5))

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

Ie. checks the command line, ezFileserve.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 EZ_SUCCESS is returned. Call GetServerConnectionAddress() to retrieve the address.

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

◆ WaitForServerInfo()

ezResult ezFileserveClient::WaitForServerInfo ( ezTime  timeout = ezTime::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: