Example #1
0
        /// <summary>
        /// Unregisters a room from a server
        /// </summary>
        /// <param name="room"></param>
        public virtual void DestroyRoom(RegisteredRoom room)
        {
            var peer = room.Peer;

            if (peer != null)
            {
                var peerRooms = peer.GetProperty((int)MsfPropCodes.RegisteredRooms) as Dictionary <string, RegisteredRoom>;

                // Remove the room from peer
                if (peerRooms != null)
                {
                    peerRooms.Remove(room.RoomId);
                }
            }
            // Remove the room from all rooms
            Rooms.Remove(room.RoomId);

            room.Destroy();

            // Invoke the event
            if (RoomDestroyed != null)
            {
                RoomDestroyed.Invoke(room);
            }
        }
Example #2
0
        /// <summary>
        /// Sends a request to destroy a room of a given room id
        /// </summary>
        public void DestroyRoom(int roomId, SuccessCallback callback, IClientSocket connection)
        {
            if (!connection.IsConnected)
            {
                callback.Invoke(false, "Not connected");
                return;
            }

            connection.SendMessage((short)OpCodes.DestroyRoom, roomId, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    callback.Invoke(false, response.AsString("Unknown Error"));
                    return;
                }

                _localCreatedRooms.TryGetValue(roomId, out var destroyedRoom);
                _localCreatedRooms.Remove(roomId);

                callback.Invoke(true, null);

                // Invoke event
                if (destroyedRoom != null)
                {
                    RoomDestroyed?.Invoke(destroyedRoom);
                }
            });
        }
Example #3
0
        /// <summary>
        /// Sends a request to destroy a room of a given room id
        /// </summary>
        public void DestroyRoom(int roomId, SuccessCallback successCallback, ErrorCallback errorCallback, IClient client)
        {
            if (!client.IsConnected)
            {
                errorCallback.Invoke("Not connected");
                return;
            }

            client.SendMessage((ushort)OpCodes.DestroyRoom, roomId, (status, response) =>
            {
                if (status != ResponseStatus.Success)
                {
                    errorCallback.Invoke(response.AsString("Unknown Error"));
                    return;
                }

                _localCreatedRooms.TryGetValue(roomId, out var destroyedRoom);
                _localCreatedRooms.Remove(roomId);

                successCallback.Invoke();

                // Invoke event
                if (destroyedRoom != null)
                {
                    RoomDestroyed?.Invoke(destroyedRoom);
                }
            });
        }
Example #4
0
        /// <summary>
        /// Unregisters a room from a server
        /// </summary>
        /// <param name="room"></param>
        public virtual void DestroyRoom(RegisteredRoom room)
        {
            var peer = room.Peer;

            if (peer != null)
            {
                var peerRooms = peer.GetProperty((int)PeerPropertyKeys.RegisteredRooms) as Dictionary <int, RegisteredRoom>;

                // Remove the room from peer
                peerRooms?.Remove(room.RoomId);
            }

            // Remove the room from all rooms
            _rooms.Remove(room.RoomId);

            room.Destroy();

            // Invoke the event
            RoomDestroyed?.Invoke(room);
        }