示例#1
0
        private void onConnection(BaseEvent evt)
        {
            bool   flag = (bool)evt.Params["success"];
            string text = (string)evt.Params["errorMessage"];

            if (flag)
            {
                if (mt.UseEncryption)
                {
                    mt.TriggerInitCrypto = true;
                }
                else
                {
                    mt.login();
                }
                return;
            }
            if (mt.ConnectionAttempts < 3)
            {
                mt.reconnect();
                return;
            }
            Log.LogNetworkErrorFormatted(this, "Failed to connect after {0} attempts with error: {1}. Will trigger a ROOM_JOIN_ERROR", mt.ConnectionAttempts, text);
            RoomJoinError roomJoinError = default(RoomJoinError);

            roomJoinError.roomName     = mt.JoinRoomDataRoom;
            roomJoinError.errorMessage = text;
            mt.teardown();
            mt.triggerEvent(GameServerEvent.ROOM_JOIN_ERROR, roomJoinError);
        }
示例#2
0
        public void JoinRoom(SignedResponse <JoinRoomData> signedJoinRoomData)
        {
            mt.SignedJoinRoomData = signedJoinRoomData;
            waitForRoomJoinEvent  = true;
            if (!mt.isConnected)
            {
                mt.connect(signedJoinRoomData.Data.host, signedJoinRoomData.Data.tcpPort, signedJoinRoomData.Data.httpsPort);
                return;
            }
            if (!mt.isLoggedIn)
            {
                mt.login();
                return;
            }
            string clientRoomName = mt.ClientRoomName;

            if (clientRoomName != null && clientRoomName == signedJoinRoomData.Data.room)
            {
                mt.triggerEvent(GameServerEvent.ROOM_JOIN, clientRoomName);
                return;
            }
            RoomJoinError roomJoinError = default(RoomJoinError);

            roomJoinError.roomName     = signedJoinRoomData.Data.room;
            roomJoinError.errorMessage = "Already logged in";
            mt.triggerEvent(GameServerEvent.ROOM_JOIN_ERROR, roomJoinError);
        }