/// <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) { // If we are not connected if (!connection.IsConnected) { callback?.Invoke(null, "Not connected"); return; } // Set region to room by filter. If region is empty the room will be international options.Set(MstDictKeys.roomRegion, string.IsNullOrEmpty(region) ? string.Empty : region); // Create spawn request message packet var data = new ClientsSpawnRequestPacket() { // Options for spawners module Options = options, // Options that will be send to room CustomOptions = customOptions }; // Send request to Master Server SpawnerModule connection.SendMessage((short)MstMessageCodes.ClientsSpawnRequest, data, (status, response) => { // If spawn request failed if (status != ResponseStatus.Success) { Logs.Error($"An error occurred when spawn request [{response.AsString()}]"); callback?.Invoke(null, response.AsString()); return; } // Create new spawn request controller var controller = new SpawnRequestController(response.AsInt(), connection, options); // List controler by spawn task id _localSpawnRequests[controller.SpawnTaskId] = controller; Logs.Debug($"Room was successfuly started with client options: {data.Options.ToReadableString()}, {data.CustomOptions.ToReadableString()}"); callback?.Invoke(controller, null); }); }
/// <summary> /// Retrieves a specific spawn request controller /// </summary> /// <param name="spawnId"></param> /// <returns></returns> public bool TryGetRequestController(int spawnId, out SpawnRequestController controller) { controller = GetSpawnRequestController(spawnId); return(controller != null); }