예제 #1
0
        /// <summary> 登录测试
        /// </summary>
        /// <param name="stationId"></param>
        /// <param name="userId"></param>
        /// <param name="pwd"></param>
        /// <param name="code"></param>
        /// <returns></returns>
        public static string LoginTest(string stationId, string userId, string pwd, string code)
        {
            LoginProtocol protocol = GetLoginProtocol();

            protocol.StationId      = stationId;
            protocol.UserId         = userId;
            protocol.Password       = pwd;
            protocol.PermissionCode = code;

            MessageProtocol mp = ServiceAgent.SendAndReceiveMessage(protocol);

            if (mp != null && mp.GetRealProtocol() is ResultProtocol)
            {
                ResultProtocol result = mp.GetRealProtocol() as ResultProtocol;
                if (result.Result == DataSources.EnumResultType.Success.ToString("d"))
                {
                    return(string.Empty);
                }
                else
                {
                    string msg = "登录消息(数据端口):" + DataSources.GetDescription(typeof(DataSources.EnumResultType), result.Result);
                    //写入日志
                    Log.writeCloudLog(msg);
                    return(DataSources.GetDescription(typeof(DataSources.EnumResultType), result.Result));
                }
            }
            return("返回协议格式不正确");
        }
예제 #2
0
    public void Submit()
    {
        user_id  = user_id.Trim();
        password = password.Trim();

        if (user_id.Length == 0)
        {
            //			mainObject.GetComponent<Main>().CreateMessageBox("User ID Required");
            GUI.FocusControl("username_field");
        }
        else if (password.Length == 0)
        {
            //			mainObject.GetComponent<Main>().CreateMessageBox("Password Required");
            GUI.FocusControl("password_field");
        }
        else
        {
            NetworkManager.Send(
                LoginProtocol.Prepare(user_id, password),
                ProcessLogin
                );

            CW.NetworkManager.Send(CW.LoginProtocol.Prepare(user_id, password));

            RR.RRConnectionManager cManager = RR.RRConnectionManager.getInstance();
            cManager.Send(RR_RequestLogin(user_id, password));
        }
    }
    private void Start()
    {
        if (state == NETWORK_STATE.LOCAL_HOST)
        {
            this.serverIP = "127.0.0.1";
        }
        else
        {
            this.serverIP = "10.211.55.3";
        }

        if (!Network.Instance.IsConnected)
        {
            Network.Instance.Initialize();
            ProtocolManager.Instance.Initialize();
            Network.Instance.Connect(this.serverIP, Defines.SERVER_PORT);
        }

        this.loginProtocol = transform.Find("Login Protocol").GetComponent <LoginProtocol>();
        this.lobbyProtocol = transform.Find("Lobby Protocol").GetComponent <LobbyProtocol>();
        this.roomProtocol  = transform.Find("Room Protocol").GetComponent <RoomProtocol>();
        this.testProtocol  = transform.Find("Test Protocol").GetComponent <TestProtocol>();
        this.gameProtocol  = transform.Find("Game Protocol").GetComponent <GameProtocol>();

        this.loginProtocol.InitializeProtocol();
        this.lobbyProtocol.InitializeProtocol();
        this.roomProtocol.InitializeProtocol();
        this.testProtocol.InitializeProtocol();
        this.gameProtocol.InitializeProtocol();

        //Network.Instance.Connect(this.serverIP, Defines.SERVER_PORT);
    }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetKeyDown(KeyCode.Space))
     {
         LoginProtocol loginProtocol = new LoginProtocol()
         {
             userId = "hello", userPassword = "******"
         };
         ClientManager.instance.SendMessage(loginProtocol);
     }
 }
예제 #5
0
        /// <summary>
        /// 获取登录协议
        /// </summary>
        /// <returns></returns>
        private static LoginProtocol GetLoginProtocol()
        {
            LoginProtocol protocol = new LoginProtocol();

            protocol.StationId      = GlobalStaticObj_Server.Instance.StationID;
            protocol.SubMessageId   = SubMessageId;
            protocol.TimeSpan       = TimeHelper.GetTimeInMillis();
            protocol.UserId         = GlobalStaticObj_Server.Instance.Cloud_UserId;
            protocol.Password       = GlobalStaticObj_Server.Instance.Cloud_Password;
            protocol.PermissionCode = GlobalStaticObj_Server.Instance.LicenseCode;
            return(protocol);
        }
예제 #6
0
    public void Login()
    {
        LoginProtocol loginProtocol = new LoginProtocol()
        {
            userId       = idInput.text,
            userPassword = passwordInput.text
        };

        ClientManager.instance.SendMessage(loginProtocol);
        ClientManager.instance.receiveCallBack += LoginReceive;

        messageText.text           = "";
        idInput.interactable       = false;
        passwordInput.interactable = false;
    }
예제 #7
0
        public override void Execute(Protocol protocol, ClientToken client)
        {
            if (protocol.GetType() != typeof(LoginProtocol))
            {
                return;
            }

            LoginProtocol loginProtocol = protocol as LoginProtocol;

            Console.WriteLine("登录服务运行,账号为:" + loginProtocol.userId + ",密码为:" + loginProtocol.userPassword + ";");

            AccountDatabase accountDatabase = server.databases[typeof(AccountDatabase)] as AccountDatabase;

            //查询是否有用户名密码相符的用户
            if (accountDatabase.Find(x => (x.Id == loginProtocol.userId && x.Password == loginProtocol.userPassword)) != null)
            {
                //登录成功
                LoginSuccessProtocol loginSuccessProtocol = new LoginSuccessProtocol();
                //生成令牌
                loginSuccessProtocol.PassBadge = 0;

                Byte[] serializedProtocol = ProtocolHelper.ConvertProtocolToBytes(loginSuccessProtocol);
                Byte[] encodingData       = GameProtocol.Encoder.Encode(serializedProtocol);

                client.WriteSendData(encodingData);
            }
            else
            {
                //登录失败
                LoginFailedProtocol loginFailedProtocol = new LoginFailedProtocol();
                if (accountDatabase.Find(x => (x.Id == loginProtocol.userId)) != null)
                {
                    loginFailedProtocol.State = LoginFailedState.WrongPassword;
                }
                else
                {
                    loginFailedProtocol.State = LoginFailedState.WrongID;
                }
                Byte[] serializedProtocol = ProtocolHelper.ConvertProtocolToBytes(loginFailedProtocol);
                Byte[] encodingData       = GameProtocol.Encoder.Encode(serializedProtocol);

                client.WriteSendData(encodingData);
            }
        }
예제 #8
0
        static void SerailizingTestCase()
        {
            LoginProtocol loginProtocol = new LoginProtocol()
            {
                userId = "abc", userPassword = "******"
            };

            Byte[] bytes = ProtocolHelper.ConvertProtocolToBytes(loginProtocol);

            var result = ProtocolHelper.ConvertBytesToProtocol(bytes);

            if (result != null)
            {
                Debug.Log("序列化成功");
            }
            else
            {
                Debug.Log("序列化失败");
            }
        }
예제 #9
0
        private void SendMessage(object state)
        {
            string[] arrays = state.ToString().Split('$');
            if (arrays.Length != 8)
            {
                return;
            }
            LoginProtocol lp = new LoginProtocol();

            lp.StationId    = arrays[0];
            lp.SerialNumber = arrays[1];
            lp.MessageId    = arrays[2];
            lp.SubMessageId = arrays[3];
            lp.TimeSpan     = arrays[4];

            lp.UserId         = arrays[5];
            lp.Password       = arrays[6];
            lp.PermissionCode = arrays[7];

            ServiceAgent.AddSendQueue(lp);
            FileAgent.AddSendQueue(lp);
        }
예제 #10
0
        /// <summary>
        /// 附件登录
        /// </summary>
        /// <returns></returns>
        public static bool FileLogin()
        {
            LoginProtocol   protocol = GetLoginProtocol();
            MessageProtocol mp       = FileAgent.SendAndReceiveMessage(protocol);

            if (mp != null && mp.GetRealProtocol() is ResultProtocol)
            {
                ResultProtocol result = mp.GetRealProtocol() as ResultProtocol;
                if (result.Result == DataSources.EnumResultType.Success.ToString("d"))
                {
                    Log.writeCloudLog("云平台文件通讯-登录成功!");
                    return(true);
                }
                else
                {
                    string msg = "登录消息(附件端口):" + DataSources.GetDescription(typeof(DataSources.EnumResultType), result.Result);
                    //写入日志
                    Log.writeLog(msg);
                }
            }
            return(false);
        }
예제 #11
0
        public fmQQList()
        {
            this.SetStyle(ControlStyles.DoubleBuffer
                          | ControlStyles.UserPaint
                          | ControlStyles.AllPaintingInWmPaint,
                          true);
            this.UpdateStyles();

            InitializeComponent();
            tbVerifyCode.Enabled = false;
            cboLoginStatus.Items.AddRange(LoginStatus[0].Cast <object>().ToArray());
            cboLoginProtocol.Items.AddRange(LoginProtocol.Cast <object>().ToArray());
            cboVerifyCodeDigit.Items.AddRange(VerifyCodeDigit.Cast <object>().ToArray());
            cboLoginStatus.SelectedIndex     = 0;
            cboLoginProtocol.SelectedIndex   = 0;
            cboVerifyCodeDigit.SelectedIndex = 0;
            chkAutoReply.Checked             = false;
            chkUseRobot.Checked = false;

            _notifyIcon = new NotifyIcon()
            {
                Text = this.Text, Visible = true, Icon = Icon
            };

            _notifyIcon.DoubleClick += (sender, args) =>
            {
                if (this.WindowState == FormWindowState.Minimized)
                {
                    this.Show();
                    this.WindowState = FormWindowState.Normal;
                    // this.ShowInTaskbar = true;
                }
                else
                {
                    this.WindowState = FormWindowState.Minimized;
                }
            };
            _notifyIcon.ContextMenu = new ContextMenu();
        }