_NetworkEvents

Inherits: Node

This class provides convenience signals for multiplayer games.

Description

While the client start/stop and peer join/leave events are trivial, the server side has no similar events. This means that if you'd like to add some funcionality that should happen on server start, you either have to couple the code ( i.e. call it wherever you start the server ) or introduce a custom event to decouple your code from your network init code.

By providing these convenience events, you can forego all that and instead just listen to a single signal that should work no matter what.

Note: This class also manages _NetworkTime start/stop, so as long as network events are enabled, you don't need to manually call start/stop.

Properties

Type Name Default
bool enabled

Methods

Return Type Name
bool is_server()

Signals

on_multiplayer_change ( MultiplayerAPI old, MultiplayerAPI new )

Event emitted when the MultiplayerAPI is changed


on_server_start ( )

Event emitted when the server starts


on_server_stop ( )

Event emitted when the server stops for any reason


on_client_start ( int id )

Event emitted when the client starts


on_client_stop ( )

Event emitted when the client stops.

This can happen due to either the client itself or the server disconnecting for whatever reason.


on_peer_join ( int id )

Event emitted when a new peer joins the game.


on_peer_leave ( int id )

Event emitted when a peer leaves the game.


Property Descriptions

bool enabled

Whether the events are enabled.

Events are only emitted when it's enabled. Disabling this can free up some performance, as when enabled, the multiplayer API and the host are continuously checked for changes.

The initial value is taken from the Netfox project settings.


Method Descriptions

bool is_server ( )

Check if we're running as server.