Esempio 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, RoomAccessCallback callback, string password,
                              Dictionary <string, string> properties)
        {
            if (!Connection.IsConnected)
            {
                callback.Invoke(null, "Not connected");
                return;
            }

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

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

                var access = response.Deserialize(new RoomAccessPacket());

                LastReceivedAccess = access;

                callback.Invoke(access, null);

                AccessReceived?.Invoke(access);

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