Exemplo n.º 1
0
        /// <summary>
        ///     Tries to get an access to a room with a given room id, password,
        ///     and some other properties, which will be visible to the room (game server)
        /// </summary>
        public void GetAccess(int roomId, string password, Dictionary <string, string> properties, RoomAccessCallback callback,
                              ErrorCallback errorCallback)
        {
            if (!Client.IsConnected)
            {
                errorCallback.Invoke("Not connected");
                return;
            }

            var packet = new RoomAccessRequestPacket
            {
                RoomId     = roomId,
                Properties = properties,
                Password   = password
            };

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

                var access = response.Deserialize <RoomAccessPacket>();

                LastReceivedAccess = access;

                callback.Invoke(access);

                AccessReceived?.Invoke(access);

                if (RoomConnector.Instance != null)
                {
                    RoomConnector.Connect(access);
                }
            });
        }
Exemplo n.º 2
0
 protected virtual void OnDestroy()
 {
     Instance = null;
 }
Exemplo n.º 3
0
 protected virtual void Awake()
 {
     Instance = this;
 }