Spawner
This system allows you to run your game servers anywhere in the world. For example, you have launched a master server in England, but you want players from the United States, Russia, Japan, and China to be able to play your game in their countries. To do this, you run VDS in these countries and install a system to run your game servers with the specified region. The region is needed to select the game server. After you launch the spawners, they will be immediately registered in the master server system and will be available to any client and ready to launch the game servers.
Client Side
There are several methods for working with the spawner on the client side.
RequestSpawn()
This method makes a request to the master server to start the game server with the specified parameters.
/// <summary>
/// Sends a request to master server, to spawn a process with given options
/// </summary>
/// <param name="options"></param>
public void RequestSpawn(MstProperties options)
/// <summary>
/// Sends a request to master server, to spawn a process in a given region, and with given options
/// </summary>
/// <param name="options"></param>
public void RequestSpawn(MstProperties options, string region)
/// <summary>
/// Sends a request to master server, to spawn a process in a given region, and with given options
/// </summary>
/// <param name="options"></param>
/// <param name="region"></param>
/// <param name="callback"></param>
public void RequestSpawn(MstProperties options, string region, SpawnRequestResultHandler callback)
/// <summary>
/// Sends a request to master server, to spawn a process in a given region, and with given options
/// </summary>
/// <param name="options"></param>
/// <param name="region"></param>
/// <param name="callback"></param>
public void RequestSpawn(MstProperties options, MstProperties customOptions, string region, SpawnRequestResultHandler callback)
/// <summary>
/// Sends a request to master server, to spawn a process in a given region, and with given options
/// </summary>
/// <param name="options"></param>
/// <param name="customOptions"></param>
/// <param name="region"></param>
/// <param name="callback"></param>
public void RequestSpawn(MstProperties options, MstProperties customOptions, string region, SpawnRequestResultHandler callback, IClientSocket connection)
- options - this parameter is necessary for transmitting any settings or commands to the spawner itself. These options may be different, depending on whether you have extended the spawner or use a provided solution.
- customOptions - this is what will be passed directly to the game server processes that are running. You must write command-line arguments to this parameter.
- region - this parameter is required to specify the region where the game server will be launched. Setting this parameter is only necessary if your spawner is registered in any region. By default, all the spawners are registered as "international", in this case, the "region" parameter should be empty.
- callback - this parameter specifies a method that accepts two parameters:
- controller - controller for the process being started.
- error - result with an error, if it occurred.
AbortSpawn()
This method is used to stop the game server process being started.
/// <summary>
/// Sends a request to abort spawn request, which was not yet finalized
/// </summary>
/// <param name="spawnTaskId"></param>
public void AbortSpawn(int spawnTaskId)
/// <summary>
/// Sends a request to abort spawn request, which was not yet finalized
/// </summary>
public void AbortSpawn(int spawnTaskId, SuccessCallback callback)
/// <summary>
/// Sends a request to abort spawn request, which was not yet finalized
/// </summary>
/// <param name="spawnTaskId"></param>
/// <param name="callback"></param>
/// <param name="connection"></param>
public void AbortSpawn(int spawnTaskId, SuccessCallback callback, IClientSocket connection)
This method also has several parameters. Let's look at them.
- spawnTaskId - ID of the task to launch. This ID can be obtained from the controller that gives you the RequestSpawn method in the callback parameter.
- callback - this parameter specifies the method that returns the result of the process completion operation to you.
GetFinalizationData()
This method executes a request to get data about the completion of the game server startup process. This data is given by the spawner to the master server.
/// <summary>
/// Retrieves data, which was given to master server by a spawned process,
/// which was finalized
/// </summary>
/// <param name="spawnId"></param>
/// <param name="callback"></param>
public void GetFinalizationData(int spawnId, FinalizationDataResultHandler callback)
/// <summary>
/// Retrieves data, which was given to master server by a spawned process,
/// which was finalized
/// </summary>
public void GetFinalizationData(int spawnId, FinalizationDataResultHandler callback, IClientSocket connection)
This method has the following parameters:
- spawnId - ID of the running process.
- callback - this parameter specifies the method that returns the result with data.
- data - list of data.
- error - result with an error, if it occurred.
GetSpawnRequestController()
This method is necessary to get the controller of the started process of game server.
/// <summary>
/// Retrieves a specific spawn request controller
/// </summary>
/// <param name="spawnId"></param>
/// <returns></returns>
public SpawnRequestController GetSpawnRequestController(int spawnId)
This method has the following parameters:
- spawnId - ID of the running process.
Returns SpawnRequestController.