Beispiel #1
0
    void Login()
    {
        MsgLogin msgLogin = new MsgLogin();

        msgLogin.AccountId = UserNmae;
        NetManager.Instance.SendMessage("MsgLogin", msgLogin);
    }
Beispiel #2
0
    //发送登陆协议
    public void OnLoginClick()
    {
        MsgLogin msg = new MsgLogin();

        msg.id = idInput.text;
        msg.pw = pwInput.text;
        NetManager.Send(msg);
    }
        public static void Process(ClientSocket clientSocket, MsgDH packet)
        {
            var b = packet.GetPayload();

            clientSocket.Diffie.HandleResponse(Encoding.ASCII.GetString(b));
            clientSocket.Crypto = new Crypto(clientSocket.Diffie.Key);
            clientSocket.Send(MsgLogin.Create("asd", "asdasd", false, MsgLoginType.Login));
        }
Beispiel #4
0
        private void OnConnected(INetwork network, IChannel channel)
        {
            Debug.Log("Connect server successfully.");

            var msg = new MsgLogin();

            msg.name = "玩家" + new System.Random().Next(1000);
            SendPacket((int)MsgTypeCmd.Login, msg);
        }
Beispiel #5
0
        internal static void Handle(MsgLogin packet)
        {
            var player = TestingScene.Player;

            player.Entity.Add(new NetworkComponent(packet.UniqueId));
            World.RegisterUniqueIdFor(player.Entity.EntityId, packet.UniqueId);

            var     child = World.GetEntity(player.Entity.Children.Find(c => World.GetEntity(c).Has <TextComponent>()));
            ref var txt   = ref child.Get <TextComponent>();
Beispiel #6
0
        /// <summary>
        /// 处理登录信息
        /// </summary>
        /// <param name="c"></param>
        /// <param name="msgBase"></param>
        public static void MsgLogin(ClientSocket c, MsgBase msgBase)
        {
            MsgLogin    msg = (MsgLogin)msgBase;
            LoginResult rst = UserManager.Instance.Login(msg.LoginType, msg.Account, msg.Password, out int userid, out string token);

            msg.Result = rst;
            msg.Token  = token;
            c.UserId   = userid;
            ServerSocket.SendMessage(c, msg);
        }
Beispiel #7
0
    //登陆协议处理
    public static void MsgLogin(ClientState c, MsgBase msgBase)
    {
        MsgLogin msg = (MsgLogin)msgBase;

        //密码校验
        if (!DbManager.CheckPassword(msg.id, msg.pw))
        {
            msg.result = 1;
            NetManager.Send(c, msg);
            return;
        }

        //不允许再次登陆
        if (c.player != null)
        {
            msg.result = 1;
            NetManager.Send(c, msg);
            return;
        }

        //如果已经登陆,踢下线
        if (PlayerManager.IsOnline(msg.id))
        {
            //发送踢下线协议
            Player  other   = PlayerManager.GetPlayer(msg.id);
            MsgKick msgKick = new MsgKick();
            msgKick.reason = 0;
            other.Send(msgKick);
            //断开连接
            NetManager.Close(other.state);
        }

        //获取玩家数据
        PlayerData playerData = DbManager.GetPlayerData(msg.id);

        if (playerData == null)
        {
            msg.result = 1;
            NetManager.Send(c, msg);
            return;
        }

        //构建Player
        Player player = new Player(c);

        player.id   = msg.id;
        player.data = playerData;
        PlayerManager.AddPlayer(msg.id, player);
        c.player = player;
        //返回协议
        msg.result = 0;
        player.Send(msg);
    }
Beispiel #8
0
        public static async Task Main()
        {
            FConsole.WriteLine("Host: ");
            ServerHostname       = Console.ReadLine().Trim();
            Client.OnConnected  += Connected;
            Client.OnPacket     += PacketRouter.Handle;
            Client.OnDisconnect += Disconnected;
            Client.ConnectAsync(ServerHostname, ServerPort);

            while (true)
            {
                var msg = Console.ReadLine();

                switch (msg)
                {
                case "login":
                    Client.Send(MsgLogin.Create("asd", "asdasd", true, MsgLoginType.Login));
                    break;

                case "ping":
                    var array  = new byte[MsgBench.MAX_ARRAY_LENGTH];
                    var random = new Random();
                    for (var i = 0; i < array.Length; i++)
                    {
                        array[i] = (byte)random.Next(0, 255);
                    }
                    Stopwatch.Start();
                    for (var i = 0; i < 1000; i++)
                    {
                        var msgBench = MsgBench.Create(array, false);
                        Client.Send(msgBench);
                    }
                    break;

                case "send":
                    var user = (User)Client.StateObject;
                    FConsole.WriteLine("Requesting Token...");
                    user.Send(MsgToken.Create("transcoder", 0, true));
                    while (!user.Tokens.ContainsKey(0))
                    {
                        Thread.Sleep(1);
                    }
                    FConsole.WriteLine("Uploading... using " + user.Tokens[0]);
                    Stopwatch.Start();
                    await user.SendFile(@"/home/alumni/transcoder", 0);

                    Stopwatch.Stop();
                    FConsole.WriteLine($"Done. {Stopwatch.Elapsed.TotalSeconds.ToString("##.##")}");
                    break;
                }
            }
        }
Beispiel #9
0
    /// <summary>
    /// 登录协议的提交
    /// </summary>
    /// <param name="loginType"></param>
    /// <param name="userName"></param>
    /// <param name="password"></param>
    /// <param name="callback"></param>
    public static void Login(LoginType loginType, string userName, string password, Action <LoginResult, string> callback)
    {
        MsgLogin msg = new MsgLogin();

        msg.Account   = userName;
        msg.Password  = password;
        msg.LoginType = loginType;
        NetManager.Instance.SendMessage(msg);
        NetManager.Instance.AddProtoListener(ProtocolEnum.MsgLogin, (resmsg) =>
        {
            MsgLogin msgLogin = (MsgLogin)resmsg;
            callback(msgLogin.Result, msgLogin.Token);
        });
    }
 internal static void Handle(Player player, MsgLogin packet)
 {
     player.UniqueId = packet.UniqueId;
     var(user, pass) = packet.GetUserPass();
     ThreadedConsole.WriteLine("[Net][MsgLogin] Login Packet for Player " + user + " using password: "******"[Net][MsgLogin] " + user + " failed to authenticate! (not implemented)");
     }
     else
     {
         ThreadedConsole.WriteLine("[Net][MsgLogin] " + user + " authenticated! (not implemented)");
     }
 }
Beispiel #11
0
    //收到登陆协议
    public void OnMsgLogin(MsgBase msgBase)
    {
        MsgLogin msg = (MsgLogin)msgBase;

        if (msg.result == 0)
        {
            Debug.Log("登陆成功");
            SceneManager.LoadScene("02-Lobby");
        }
        else
        {
            Debug.Log("登陆失败");
        }
    }
 public override void ProcessMessage(MessageBase tmpMsg)
 {
     if (tmpMsg.m_msgId == (int)PhotonManager.MsgType.Login)
     {
         MsgLogin msgLogin = (MsgLogin)tmpMsg;
         if (msgLogin != null)
         {
             Login(msgLogin.user);
         }
         else
         {
             Debug.LogError("Conver msg to MsgLogin error!");
         }
     }
 }
Beispiel #13
0
    // 玩家点击登陆按钮
    public void OnLoginClick()
    {
        MsgLogin msg = new MsgLogin();

        msg.id = idInput.text;
        msg.pw = pwInput.text;
        if (msg.id != "" && msg.pw != "")
        {
            NetManager.Send(msg);
        }
        else
        {
            Debug.Log("id or pw can't be empty string");
        }
    }
Beispiel #14
0
    //当按下登陆按钮
    public void OnLoginClick()
    {
        //用户名密码为空
        if (_idInput.text == "" || _pwInput.text == "")
        {
            PanelManager.Open <TipPanel>("用户名和密码不能为空");
            return;
        }
        //发送
        MsgLogin msgLogin = new MsgLogin();

        msgLogin.Id = _idInput.text;
        msgLogin.Pw = _pwInput.text;
        NetManager.Send(msgLogin);
    }
Beispiel #15
0
    //收到登陆协议
    public void OnMsgLogin(MsgBase msgBase)
    {
        MsgLogin msg = (MsgLogin)msgBase;

        if (msg.result == 0)
        {
            Debug.Log("登陆成功");
            //请求记事本文本
            MsgGetText msgGetText = new MsgGetText();
            NetManager.Send(msgGetText);
        }
        else
        {
            Debug.Log("登陆失败");
        }
    }
Beispiel #16
0
    //当按下登陆按钮
    public void OnLoginClick()
    {
        // Close();
        // PanelManager.Open<SelectPlayerPanel>();
        //用户名密码为空
        if (idInput.text == "" || pwInput.text == "")
        {
            PanelManager.Open <TipPanel>("用户名和密码不能为空");
            return;
        }
        //发送
        MsgLogin msgLogin = new MsgLogin();

        msgLogin.id = idInput.text;
        msgLogin.pw = pwInput.text;
        NetManager.Send(msgLogin);
    }
Beispiel #17
0
        private static void OnLogin(MsgBase msgBase)
        {
            MsgLogin    msgLogin    = (MsgLogin)msgBase;
            LoginScence loginScence = ContainerBuilder.Resolve <LoginScence>();

            if (msgLogin.code != HttpStatusCode.OK)
            {
                Console.WriteLine(msgLogin.result);
            }
            else
            {
                User user = JsonConvert.DeserializeObject <User>(msgLogin.result);
                ScenceController.user      = user;
                ScenceController.curScence = ScenceController.scenceDict["index"];
            }
            loginScence.IsLoignCallBack = true;
        }
    //收到登陆协议
    public void OnMsgLogin(MsgBase msgBase)
    {
        MsgLogin msg = (MsgLogin)msgBase;

        if (msg.result == 0)
        {
            Debug.Log("登陆成功");
            //设置id
            GameMain.id = msg.id;
            //打开房间列表界面
            //PanelManager.Open<RoomListPanel>();
            //关闭界面
            Close();
        }
        else
        {
            PanelManager.Open <TipPanel>("登陆失败");
        }
    }
Beispiel #19
0
        public static async Task Main()
        {
            AppDomain.CurrentDomain.UnhandledException += (sender, a) =>
            {
                Debugger.Break();
            };
            Console.Title = "CLIENT APP";
            LoadConfig();

            if (await Client.ConnectAsync(SERVER_IP, SERVER_PORT))
            {
                Client.Send(MsgLogin.Create("user", "pass"));
            }

            while (true)
            {
                Console.ReadLine();
            }
        }
Beispiel #20
0
    //收到登陆协议
    public void OnMsgLogin(Request request)
    {
        MsgLogin msg = Login.MsgLogin.Parser.ParseFrom(request.Msg);

        if (msg.Result == 0)
        {
            Debug.Log("登陆成功");
            //设置id
            GameMain.id = msg.Id;
            //进入主界面
            SceneManager.LoadSceneAsync("MainMenu");
            PanelManager.Open <MainPanel>();
            //关闭界面
            Hide();
        }
        else
        {
            PanelManager.Open <TipPanel>("登陆失败");
        }
    }
Beispiel #21
0
        public static void Process(MsgLogin msgLogin)
        {
            if (msgLogin.UniqueId != 0)
            {
                Core.MyUser          = new User();
                Core.MyUser.Id       = msgLogin.UniqueId;
                Core.MyUser.Username = msgLogin.GetUsername();
                Core.MyUser.Password = msgLogin.GetPassword();
                Core.Client.Socket.UseCompression = msgLogin.ClientSupportCompression;
                FConsole.WriteLine("Authentication successful. Your Username Id is: " + Core.MyUser.Id);
                var msgDataRequest = MsgDataRequest.CreateFriendListRequest(Core.MyUser.Id);
                Core.Client.Send(msgDataRequest);
            }
            else
            {
                FConsole.WriteLine("Authentication failed.");
            }

            FConsole.WriteLine($"MsgLogin Deserializing & Processing took {(((float)PacketRouter.Stopwatch.ElapsedTicks) / Stopwatch.Frequency) * 1000000000} ns");
        }
Beispiel #22
0
        public static void Process(MsgLogin msgLogin)
        {
            if (msgLogin.UniqueId != 0)
            {
                Core.MyUser          = new User();
                Core.MyUser.Id       = msgLogin.UniqueId;
                Core.MyUser.Username = msgLogin.GetUsername();
                Core.MyUser.Password = msgLogin.GetPassword();
                FConsole.WriteLine("Authentication successful. Your user Id is: " + Core.MyUser.Id);
                Core.Client.OnLoggedIn?.Invoke();
                var msgDataRequest = MsgDataRequest.CreateFriendListRequest(Core.MyUser.Id);
                Core.Client.Send(msgDataRequest);
            }
            else
            {
                FConsole.WriteLine("Authentication failed.");
            }

            FConsole.WriteLine($"MsgLogin: {PacketRouter.Stopwatch.Elapsed.TotalMilliseconds:0.0000}ms");
        }
Beispiel #23
0
        public static void MsgLogin(ClientState c, MsgBase msg)
        {
            Debug.WriteLine("MsgLogin");
            MsgLogin msgLogin = (MsgLogin)msg;
            User     user     = UserManager.Login(msgLogin.username, msgLogin.password, out msgLogin.result);

            if (user == null)
            {
                msgLogin.code = HttpStatusCode.NotFound;
            }
            else
            {
                msgLogin.code = HttpStatusCode.OK;
                c.user        = user;
                Player player = UserWrapper.ToPlayer(user, c);

                PlayerManager.AddPlayer(player);
                msgLogin.result = JsonConvert.SerializeObject(user);
            }
            NetManager.Send(c, msgLogin);
        }
Beispiel #24
0
    //收到登陆协议
    public void OnMsgLogin(MsgBase msgBase)
    {
        MsgLogin msg = (MsgLogin)msgBase;

        if (msg.result == 0)
        {
            Debug.Log("登陆成功");
            //设置id
            // GameMain.id = msg.id;
            //打开房间列表界面
            // PanelManager.Open<RoomListPanel>();
            PanelManager.Open <SelectPlayerPanel>();
            playersDataEnter(msg.playerSimpleInfos);
            //关闭界面
            Close();
        }
        else
        {
            PanelManager.Open <TipPanel>("登陆失败");
        }
    }
Beispiel #25
0
    //TODO
    // add more player property
    public static void MsgLogin(ClientState c, MsgBase msg)
    {
        MsgLogin m = msg as MsgLogin;

        if (c.player != null || PlayerManager.IsOnline(m.id))
        {
            m.result = 1;
            NetManager.Send(c, m);
            return;
        }
        Player p = new Player(c)
        {
            id   = m.id,
            data = new PlayerData(),
        };

        c.player = p;
        m.result = 0;

        PlayerManager.AddPlayer(c.player.id, c.player);
        p.Send(m);
    }
        void MessageLoop()
        {
            MsgLogin login = new MsgLogin();

            login.InitHeader("ahai", "gca");
            login.username = "******";
            login.password = "******";
            MessageHeader result = _TcpMessageClient.SendRecvMessage(login, 1000);

            if (result != null)
            {
                MsgText msgtext = (MsgText)result;
                Console.WriteLine(msgtext.text);
            }
            MsgUser user = new MsgUser();

            user.InitHeader("ahai", "gca");
            user.username = "******";
            user.password = "******";
            user.role     = "admin";
            if (!_TcpMessageClient.SendMessage <MsgUser>(user))
            {
                return;
            }
            MsgText text = new MsgText();

            text.InitHeader("ahai", "gca");
            do
            {
                string msg = Console.ReadLine();
                text.text = msg;
                if (!_TcpMessageClient.SendMessage <MsgText>(text))
                {
                    break;
                }
            } while (true);
        }
Beispiel #27
0
 private void Connected()
 {
     FConsole.WriteLine("Connected!");
     Core.Client.Send(MsgLogin.Create(User, Pass, "", true, MsgLoginType.Login));
 }
Beispiel #28
0
        private void BtnLogin_Click(object sender, EventArgs e)
        {
            string hostname = TxtHost.Text.ToLower().Trim();
            string username = TxtUser.Text.ToLower().Trim();
            string password = TxtPass.Text.ToLower().Trim();

            // Try to set the hostname
            if (!Network.GameComms.SetHost(hostname))
            {
                MessageBox.Show(this, "Please check hostname");
            }

            bool is_new_user = (Button)sender == BtnNew;

            if (username.Length > 0 && password.Length > 0)
            {
                output_username = username;
                output_password = password;

                MsgLogin msg = new MsgLogin();
                msg.Action       = (is_new_user) ? MsgLogin.ActionType.NewUser : MsgLogin.ActionType.LoginUser;
                msg.Username     = username;
                msg.PasswordHash = password;

                using (System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create())
                {
                    // Convert the password to bytes
                    byte[] pw_bytes   = Encoding.ASCII.GetBytes(output_password);
                    byte[] hash_bytes = md5.ComputeHash(pw_bytes);

                    // Convert the bytes to a hex string
                    StringBuilder sb = new StringBuilder();
                    for (int i = 0; i < hash_bytes.Length; i++)
                    {
                        sb.Append(hash_bytes[i].ToString("x2"));
                    }
                    msg.PasswordHash = sb.ToString();
                }

                try
                {
                    Network.GameComms.ResetSocket();
                }
                catch (System.Net.Sockets.SocketException)
                {
                    MessageBox.Show(this, "Unable to connect to server");
                    return;
                }

                if (chkUseSecure.Checked)
                {
                    if (!Network.GameComms.SetupSSL())
                    {
                        MessageBox.Show(this, "Unable to setup SSL connection");
                        return;
                    }
                }

                Network.GameComms.SendMessage(msg);

                MsgServerResponse msg_response = null;

                for (int i = 0; i < 10; ++i)
                {
                    MsgBase msg_b = Network.GameComms.ReceiveMessage();

                    if (msg_b == null)
                    {
                        Thread.Sleep(100);
                    }
                    else
                    {
                        if (msg_b is MsgServerResponse)
                        {
                            msg_response = (MsgServerResponse)msg_b;
                        }

                        break;
                    }
                }

                if (msg_response != null && msg_response.ResponseCode == ResponseCodes.OK)
                {
                    Network.GameComms.SetPlayer(msg_response.User);
                    DialogResult = DialogResult.OK;
                    Close();
                }
                else
                {
                    MessageBox.Show(this, "Login Failed");
                }
            }
        }
Beispiel #29
0
 public void Setup()
 {
     CachedMsg   = MsgLogin.Create("user", "pass", true, Universal.Packets.Enums.MsgLoginType.Login);
     CachedArray = CachedMsg;
 }
Beispiel #30
0
        //登录处理
        public static void MsgLogin(ClientState state, MsgBase msgBase)
        {
            MsgLogin msgLogin = (MsgLogin)msgBase;

            //密码效验
            if (!DbManager.CheckPassword(msgLogin.id, msgLogin.pw))
            {
                Console.WriteLine(" Incorrect Password Or Account Number ");

                msgLogin.result = 1;

                NetManager.Send(state, msgLogin);

                return;
            }

            //不容许再次登录
            if (state.player != null)
            {
                Console.WriteLine(" Repeated Login Is Not Allowed ");

                msgLogin.result = 1;

                NetManager.Send(state, msgLogin);

                return;
            }

            //如果已经登录,踢下线
            if (PlayerManager.IsOnline(msgLogin.id))
            {
                Player player = PlayerManager.GetPlayer(msgLogin.id);

                MsgKick msgKick = new MsgKick();

                msgKick.reason = 0;

                NetManager.Send(state, msgKick);
            }

            //获取玩家数据
            PlayerData playerData = DbManager.GetPlayerData(msgLogin.id);

            if (playerData == null)
            {
                msgLogin.result = 1;

                NetManager.Send(state, msgLogin);

                return;
            }

            //构建Player玩家
            Player player1 = new Player(state);

            player1.id = msgLogin.id;

            player1.data = playerData;

            PlayerManager.AddPlayer(msgLogin.id, player1);

            state.player = player1;

            //返回协议
            msgLogin.result = 0;

            player1.Send(msgLogin);
        }