示例#1
0
        internal static void TestProtoPacketsPerf()
        {
            short      psize;
            PUserLogin p = new PUserLogin
            {
                UserName = "******",
                Password = "******"
            };

            p.Setup();
            byte[] ps = p.Serialize();
            BasePacket.Deserialize(ps, ps.Length, 0, out psize);

            HRTimer timer = HRTimer.CreateAndStart();

            Parallel.For(0, ITERATIONS_COUNT, i =>
//            for (int i = 0; i < ITERATIONS_COUNT; i++)
            {
                p.Setup();
                ps = p.Serialize();
                BasePacket.Deserialize(ps, ps.Length, 0, out psize);
            });
//            }
            System.Console.WriteLine(timer.StopWatch());
        }
示例#2
0
    void OnGUI()
    {
        GUI.Box(CenterRect(0, -80, 300, 50), "유니티클라+자바서버 샘플");
        GUI.Box(CenterRect(0, -30, 300, 25), mesage);
        email    = GUI.TextField(CenterRect(0, 0, 150, 25), email, 30);
        password = GUI.TextField(CenterRect(0, 25, 150, 25), password, 30);

        //로그인 버튼 클릭시 처리 프로토콜 호출
        if (GUI.Button(CenterRect(0, 55, 50, 25), "login"))
        {
            PUserLogin login = new PUserLogin();
            login.sendLogin(email, password);
        }

        //로그인 상태 변경
        if (status == LoginStatus.SUCESS)
        {
            Application.LoadLevel("LobbyScene");
        }
        else if (status == LoginStatus.FAIL)
        {
            mesage = "이메일 또는 패스워드가 맞지 않습니다.";
            status = LoginStatus.WAIT;
        }
        else if (status == LoginStatus.DUPLICATE_LOGIN)
        {
            mesage = "중복 로그인으로 인한 실패";
            status = LoginStatus.WAIT;
        }
    }
示例#3
0
        private BaseResponse Login(int clientId, BasePacket packet)
        {
            PUserLogin pUserLogin = (PUserLogin)packet;

            User user = new User(pUserLogin.UserName, pUserLogin.Password);

            pUserLogin.SessionToken = BasePacket.NewSessionToken();

            Player     player     = Player.Create(user.UserName);
            ShortPoint?startPoint = World.MapFindPlayerStartPoint(player);

            if (!startPoint.HasValue)
            {
                BaseResponse.Throw("Cannot get start point for the player", ECGeneral.ServerError);
                return(null);
            }
            player.Position = startPoint.Value.ToPoint(ConstMap.PIXEL_SIZE);

            lock (_loggedPlayers)
            {
                _loggedPlayers.Add(pUserLogin.SessionToken, player.Id);
            }

            lock (_tcpClients)
            {
                _tcpClients.Add(clientId, pUserLogin.SessionToken);
                _playerClients.Add(player.Id, clientId);
            }

            World.PlayerAdd(pUserLogin.SessionToken, player);

            _validators.RegisterSession(pUserLogin.SessionToken);

            return(new RUserLogin(pUserLogin)
            {
                SessionToken = pUserLogin.SessionToken
            });
        }
示例#4
0
 public RUserLogin(PUserLogin rUserLogin)
     : base(rUserLogin)
 {
 }