Get SpatialOS

Sites

Menu

API - WorkerConnector

This document relates to the MonoBehaviour workflow.

Before reading this document, see the documentation on (MonoBehaviour) Creating workers with the WorkerConnector.

During the creation of your workers, they attempt to connect to the SpatialOS Runtime. Only a successful connection leads to the creation of a worker. Many of the fields relate to this.

Fields

Field Type Description
MaxConnectionAttempts int The number of connection attempts to make before failing to create this worker. The default is 3.
UseExternalIp bool Defines whether the workers should use the external IP to connect to the SpatialOS Runtime. This is needed for client-workers when connecting to a cloud deployment. The default is false.
Worker Worker A reference to the worker that is created upon successful connection to the SpatialOS Runtime.
OnWorkerCreationFinished Action A callback that is invoked when the worker was created successfully.

Methods

public async Task Connect(string workerType, ILogDispatcher logger);

Parameters:

  • string workerType: The type of the worker
  • ILogDispatcher logger: The logdispatcher to use for logging on this worker.

Returns: a task which finishes when the worker either connects or fails to connect.

protected abstract bool ShouldUseLocator();

Returns: true, if the worker should connect using the Locator flow, false otherwise.

protected virtual string SelectDeploymentName(DeploymentList deployments);

Only use this method when connecting through the Locator connection flow.

Parameters:

  • DeploymentList deployment: a list of all deployments for the project name specified in the spatialos.json file.

Returns: the name of the selected cloud deployment.

protected abstract ReceptionistConfig GetReceptionistConfig(string workerType);

This method is only used when connecting through the Receptionist connection flow.

Parameters:

Returns: a connection configuration to connect using the Receptionist connection flow.

protected abstract LocatorConfig GetLocatorConfig(string workerType);

This method is only used when connecting through the Locator connection flow.

Parameters:

Returns: a connection configuration to connect using the Locator connection flow stored as a LocatorConfig object.

protected virtual void HandleWorkerConnectionEstablished();

This method provides a way to add additional logic after a connection has been established.

protected virtual void HandleWorkerConnectionFailure(string errorMessage);

This method provides a way to add additional logic after the WorkerConnector failed to create a connection.

Parameters:

  • string errorMessage: Contains the reason for failing the connection.
public virtual void Dispose();

Disposes of the WorkerConnector object.

Search results

Was this page helpful?

Thanks for letting us know!

Thanks for your feedback

Need more help? Ask on the forums