コード例 #1
0
        /// <summary>
        /// Sends a request to master server, to spawn a process in a given region, and with given options
        /// </summary>
        public void RequestSpawn(Dictionary <string, string> options, string region, ClientSpawnRequestCallback callback, ErrorCallback errorCallback)
        {
            if (!Client.IsConnected)
            {
                errorCallback.Invoke("Not connected");
                return;
            }

            var packet = new ClientsSpawnRequestPacket
            {
                Options = options,
                Region  = region
            };

            Client.SendMessage((ushort)OpCodes.ClientsSpawnRequest, packet, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    errorCallback.Invoke(response.AsString("Unknown error"));
                    return;
                }

                // Spawn id
                var spawnId = response.AsInt();

                var controller = new SpawnRequestController(this, spawnId, Client);

                _localSpawnRequests[controller.SpawnId] = controller;

                callback.Invoke(controller);
            });
        }
コード例 #2
0
 protected virtual bool CanClientSpawn(IPeer peer, ClientsSpawnRequestPacket data)
 {
     return(EnableClientSpawnRequests);
 }
コード例 #3
0
 private bool CanClientSpawn(IPeer peer, ClientsSpawnRequestPacket data)
 {
     return(!_config.SpawnRequestsRequireAuthentication || peer.HasExtension <UserExtension>());
 }