protected virtual void OnMatchmakingStart(ExpandoObject data)
    {
        if (data.SafeGetString("errorCode") == "ok")          // matchmaking is finished
        {
            mMatchmaking = false;

            mRoomID = data.SafeGetValue <int>("roomID");

            if (RoomUsersData == null)
            {
                RoomUsersData = new Dictionary <int, ExpandoObject>();
            }
            else
            {
                RoomUsersData.Clear();
            }

            if (data["users"] is IList users_data)
            {
                foreach (ExpandoObject user_data in users_data)
                {
                    int user_id = Convert.ToInt32(user_data["id"]);
                    if (user_id > 0)
                    {
                        RoomUsersData[user_id] = user_data;
                    }
                }
            }

            mRoomClient               = new GameObject("SnipeRoom").AddComponent <RoomCommunicator>();
            mRoomClient.mServer       = mServer;
            mRoomClient.mHost         = data.SafeGetString("host");
            mRoomClient.mPort         = data.SafeGetValue <int>("port");
            mRoomClient.mWebSocketUrl = data.SafeGetString("webSocket");
            mRoomClient.StartCommunicator();
        }
    }
Esempio n. 2
0
    protected virtual void OnMatchmakingStart(ExpandoObject data)
    {
        if (data.SafeGetString("errorCode") == "ok")          // matchmaking is finished
        {
            mMatchmaking = false;

            if (RoomUsersData == null)
            {
                RoomUsersData = new Dictionary <int, ExpandoObject>();
            }
            else
            {
                RoomUsersData.Clear();
            }

            if (data["users"] is IList users_data)
            {
                foreach (ExpandoObject user_data in users_data)
                {
                    int user_id = Convert.ToInt32(user_data["id"]);
                    if (user_id > 0)
                    {
                        RoomUsersData[user_id] = user_data;
                    }
                }
            }

            mRoomClient = SnipeRoomCommunicator.Create <RoomCommunicator>(RoomCommunicator.ROOM_TYPE,
                                                                          data.SafeGetValue <int>("roomID"),
                                                                          mServer,
                                                                          data.SafeGetString("host"),
                                                                          data.SafeGetValue <int>("port"),
                                                                          data.SafeGetString("webSocket"));
            mRoomClient.StartCommunicator();
        }
    }