Example #1
0
        /// <summary>
        /// This should be called from a process which is spawned.
        /// For example, it can be called from a game server, which is started by the spawner
        /// On successfull registration, callback contains <see cref="SpawnTaskController"/>, which
        /// has a dictionary of properties, that were given when requesting a process to be spawned
        /// </summary>
        public void RegisterSpawnedProcess(string spawnId, string spawnCode, RegisterSpawnedProcessCallback callback,
                                           IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(null, "Not connected");
                return;
            }

            //Debug.LogError("SPWn code: " + spawnCode);
            var packet = new RegisterSpawnedProcessPacket()
            {
                SpawnCode = spawnCode,
                SpawnId   = spawnId
            };

            connection.SendMessage((short)MsfOpCodes.RegisterSpawnedProcess, packet, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(null, response.AsString("Unknown Error"));
                    return;
                }

                var properties = new Dictionary <string, string>().FromBytes(response.AsBytes());

                var process = new SpawnTaskController(spawnId, properties, connection, spawnCode);

                callback.Invoke(process, null);
            });
        }
Example #2
0
        /// <summary>
        /// This should be called from a process which is spawned.
        /// For example, it can be called from a game server, which is started by the spawner
        /// On successfull registration, callback contains <see cref="SpawnTaskController"/>, which
        /// has a dictionary of properties, that were given when requesting a process to be spawned
        /// </summary>
        public void RegisterSpawnedProcess(int spawnId, string spawnCode, RegisterSpawnedProcessCallback callback)
        {
            if (!Connection.IsConnected)
            {
                callback.Invoke(null, "Not connected");
                return;
            }

            var packet = new RegisterSpawnedProcessPacket()
            {
                SpawnCode = spawnCode,
                SpawnId   = spawnId
            };

            Connection.SendMessage((short)OpCodes.RegisterSpawnedProcess, packet, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(null, response.AsString("Unknown Error"));
                    return;
                }

                var properties = new Dictionary <string, string>().FromBytes(response.AsBytes());

                var process = new SpawnTaskController(this, spawnId, properties, Connection);

                callback.Invoke(process, null);
            });
        }
        /// <summary>
        /// This should be called from a process which is spawned.
        /// For example, it can be called from a game server, which is started by the spawner
        /// On successfull registration, callback contains <see cref="SpawnTaskController"/>, which
        /// has a dictionary of properties, that were given when requesting a process to be spawned
        /// </summary>
        public void RegisterSpawnedProcess(int spawnId, string spawnCode, RegisterSpawnedProcessCallback callback, IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(null, "Not connected");
                return;
            }

            var packet = new RegisterSpawnedProcessPacket()
            {
                SpawnCode = spawnCode,
                SpawnId   = spawnId
            };

            connection.SendMessage((short)MsfMessageCodes.RegisterSpawnedProcess, packet, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(null, response.AsString("Unknown Error"));
                    return;
                }

                // Read spawn task options received from master server
                var options = new DictionaryOptions(new Dictionary <string, string>().FromBytes(response.AsBytes()));

                // Create spawn task controller
                var process = new SpawnTaskController(spawnId, options, connection);

                callback.Invoke(process, null);
            });
        }
Example #4
0
 /// <summary>
 /// This should be called from a process, which is spawned.
 /// For example, it can be called from a game server, which is started by the spawner
 /// On successfull registration, callback contains <see cref="SpawnTaskController"/>, which
 /// has a dictionary of properties, that were given when requesting a process to be spawned
 /// </summary>
 /// <param name="spawnId"></param>
 /// <param name="spawnCode"></param>
 /// <param name="callback"></param>
 public void RegisterSpawnedProcess(string spawnId, string spawnCode, RegisterSpawnedProcessCallback callback)
 {
     RegisterSpawnedProcess(spawnId, spawnCode, callback, Connection);
 }