nanover.app.app_server module

Module providing an out-of-the-box NanoVer application server, with an underyling gRPC server, discovery, multiplayer and commands.

class nanover.app.app_server.NanoverApplicationServer(server: NanoverServer, discovery: DiscoveryServer | None = None, name: str | None = None)

Bases: object

Provides a convenient NanoVer server for typical applications, with local area network discovery provided by ESSD, multiplayer configuration and a command service.

Use this a base for building specific applications by inheriting from it and attaching additional services.

DEFAULT_SERVER_NAME: str = 'NanoVer Server'
add_service(service)

Adds a gRPC service to the server and broadcast it on discovery. :param service: Service implementation

property address: str

Address of the server. :return: Address of the server.

classmethod basic_server(name: str | None = None, address: str | None = None, port: int | None = None)

Initialises a basic NanoVer application server with default settings, with a default unencrypted server and ESSD discovery server for finding it on a local area network.

Parameters:
  • name – Name of the server for the purposes of discovery.

  • address – The address at which to bind the server to. If none given, the default address of

  • port – Optional port on which to run the NanoVer server. If none given, default port will be used.

Returns:

An instantiation of a basic NanoVer server, registered with an ESSD discovery server.

close()

Close the application server and all services.

property discovery: DiscoveryServer | None

The discovery service that can be used to allow clients to find services hosted by this application. :return: The discovery service, or None if no discovery has been set up.

Services added directly to the server running on this application via NanoverApplicationServer.add_service() are automatically added to this discovery service.

Accessing the discovery service directly enables one to register their own server that may be running separately to the core application.

property name: str

Name of the server. :return: The name of the server.

property port: int

Server port. :return: Port of the server.

property running_discovery: bool

Indicates whether a discovery service is running or not. :return: True if discovery is available, False otherwise.

property server: NanoverServer

The underlying NanoVer server for this application. One can use this to manage commands and services. :return: The NanoVer server.

class nanover.app.app_server.SupportsClose(*args, **kwargs)

Bases: Protocol

close() None
nanover.app.app_server.qualified_server_name(base_name: str)

Prefixes the given server name with identifying information of the machine running it.

nanover.app.app_server.start_default_server_and_discovery(address: str | None = None, port: int | None = None) Tuple[NanoverServer, DiscoveryServer]

Utility method for creating a default NanoVer server along with ESSD discovery.

Param:

address: Address to run the server at. If nothing is passed, the default address of all interfaces will be used.

Param:

port: Port to run the server on, if nothing is passed, the default NanoVer port will be used. The value of zero should be passed to let the OS pick a free port.

Returns:

tuple of NanoVer server and ESSD discovery.