Skip to content

Instance

Denis Totmin edited this page Aug 25, 2022 · 39 revisions

Instance

  • An abstract class that implements basic functionality for creating rooms, locations, worlds, systems, and other entities that group clients for timed interaction. It is considered part of the Hi level API and is not required to be implemented.

Properties

int Id - unique identifier of the current instance, assigned automatically by the server (read only)

int Owner - The id of the entity owner. The client with the corresponding id will think of itself as the host. This mechanism is needed for a non-authoritarian model. For authoritarian modes this value is usually not used. (read only)

AutoChangeOwner - automatic transfer of ownership when the client exits.

string Name - Public display name

byte Type - Custom byte label, for easy identification of instance type

int MaxClients - Maximum allowed number of clients

bool AutoClose - Whether to close the instance automatically in case of absence of clients

int FrameRate - number of network ticks per second (read only)

float Time.DeltaTime - time elapsed since the last network tick (in seconds)

float Time.Time - time of existence of the instance (in seconds)

NetEntityManager Entities - Network Entity Manager

string Password - password required to log in to the instance. If no value is set, no password is required

bool Visible - whether the instance is publicly visible

bool AutoUpdateClientsInfo - Whether to allow customers to automatically keep customer data up to date around

ConcurrentDictionary<BaseClient, object> Clients - Client Collection

ChatChannel ChatChannel - automatically a slave chat channel for this instancen


Methods

void SetFrameRate(int frameRate) - set the frame rate (number of ticks per second)

  • int frameRate - target number of ticks per second (10-25 values are recommended)

void AddClient(BaseClientclient,Object obj = null) - Add a client to the instance.

  • BaseClient BaseClient - the base abstract client class
  • Object obj - (optional) additional object associated with the client connection instance

void RemoveClient(BaseClient client) - client removal

BaseClient GetClientById(int id) - Receiving a customer on an id within the current instance

  • int - client id

BaseClient GetClientById<T>(int clientId) - get the client's id, and bring it to the specified type.

void RemoveClientEntities(BaseClient client) - deleting all network entities of a specified client

SendMessageToAll(byte code, BaseMessage message, GalaxyDeliveryType deliveryType) - send a message to all clients in the instance

  • byte code - custom message code
  • BaseMessage message - user message (heir of BaseMessage)
  • GalaxyDeliveryType deliveryType - way of delivering messages

SendMessageToAll(byte code, byte[] message, GalaxyDeliveryType deliveryType) - send a message to all clients in the instance

  • byte code - custom message code
  • byte[] message - user message as an array of bytes
  • GalaxyDeliveryType deliveryType - way of delivering messages

void SendMessageToAllExcept(BaseClient client, byte code, byte[] data, GalaxyDeliveryType deliveryType) - Send a message to all customers except for the specified one

void SendMessageToAllExcept(BaseClient client, byte code, BaseMessage message, GalaxyDeliveryType deliveryType) - Send a message to all customers except for the specified one

void SyncWorld(BaseClient client) - Forced synchronization of the state of all network entities in a particular client

void ChangeOwner() - Change of ownership to random

void ChangeOwner(BaseClient client) - change the owner to the specified client. If put null then the owner will be assigned to the server

void Close() - Called when an instance is closed

void Invoke(string methodName, float time, params object[] list) - Method call by name after a specified time interval with specified parameters. The called method must be public.

void void InvokeRepeating(string methodName, float time, float repeat, params object[] list) - Call a method by name at a specified time interval with specified intervals and specified parameters. The called method must be publicly available. The called method must be public.

void CancelInvoke(string methodName) - Cancel Invoke by method name


Abstract methods

void Update() - Each network frame is called (analogous to Update unity)

void InMessage(byte code, byte[] data, BaseClient client) - new incoming message

  • code - custom message code
  • data - array of bytes sent by the user
  • client- sender

void Close() - Called when an instance is closed


Virtual methods

void IncomingClient(BaseClient client) - is called when the client enters an instance

byte[] InstanceInfo - is called when the client requests information about an instance

  • return byte[] - An array of bytes with additional information attached to the response for the client

void OutcomingClient(BaseClient client) - is called when the client exits the instance

bool ValidateIncomingClient(BaseClient baseClientConnection, byte[] data) - manually check the user's access to the instance


The page was edited with the current kernel version 0.9.10

Clone this wiki locally