예제 #1
0
        static public ProtocolObject ConvertTo(JObject jso)
        {
            ProtocolObject   p    = null;
            ProtocolTypeEnum type = GetProtocolType(jso["ProtocolType"]);

            if (type == ProtocolTypeEnum.Thread)
            {
                p = new ThreadProtocol();
                ((ThreadProtocol)p).MockUserId = jso["MockUserId"].ToString();
                //if (jso["PublishUrl"] != null)
                //{
                //    ((ThreadProtocol)p).PublishUrl = jso["PublishUrl"].ToString();
                //}
            }
            else if (type == ProtocolTypeEnum.Register)
            {
                p = new RegisterProtocol();
                ((RegisterProtocol)p).MockUserId = jso["MockUserId"].ToString();
            }
            else if (type == ProtocolTypeEnum.Recorder)
            {
                p = new RecorderProtocol();
                ((RecorderProtocol)p).ScriptId  = jso["ScriptId"].ToString();
                ((RecorderProtocol)p).WebsiteId = jso["WebsiteId"].ToString();
            }
            else if (type == ProtocolTypeEnum.KeywordPlan)
            {
                p = new KeywordPlanProtocol();
            }
            else if (type == ProtocolTypeEnum.RunnerScript)
            {
                p = new ScriptRunnerProtocol();
                ((ScriptRunnerProtocol)p).ScriptId = jso["ScriptId"].ToString();
            }
            else
            {
                p = new ProtocolObject();
            }
            p.CurrentUserId    = jso["CurrentUserId"].ToString();
            p.IsAuthentication = Convert.ToBoolean(jso["IsAuthentication"]);
            // if (jso.ContainsKey("Target"))
            {
                p.Target = jso["Target"] == null ? "_blank" : jso["Target"].ToString();
            }
            p.ProtocolType = type;
            // if (jso.ContainsKey("InputParameters"))
            //{
            //    p.InputParameters = jso["InputParameters"].ToString();
            //}
            return(p);
        }
예제 #2
0
    public void Register()
    {
        RegisterProtocol registerProtocol = new RegisterProtocol()
        {
            userId       = idInput.text,
            userPassword = passwordInput.text
        };

        ClientManager.instance.SendMessage(registerProtocol);
        ClientManager.instance.receiveCallBack += RegisterReceive;

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

            RegisterProtocol registerProtocol = protocol as RegisterProtocol;

            Console.WriteLine("注册服务运行,账号为:" + registerProtocol.userId + ",密码为:" + registerProtocol.userPassword + ";");

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

            //检查是否ID已经被注册
            if (accountDatabase.Find(x => (x.Id == registerProtocol.userId)) != null)
            {
                //已被注册,返回注册失败
                RegisterFailedProtocol registerFailedProtocol = new RegisterFailedProtocol();
                registerFailedProtocol.state = RegisterFailedState.IDAlreadyExist;

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

                client.WriteSendData(encodingData);
            }
            else
            {
                //注册成功
                RegisterSuccessProtocol registerSuccessProtocol = new RegisterSuccessProtocol();
                registerSuccessProtocol.PassBadge = 0;

                //写入数据库
                accountDatabase.Write(new Account()
                {
                    Id = registerProtocol.userId, Password = registerProtocol.userPassword
                });

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

                client.WriteSendData(encodingData);
            }
        }
예제 #4
0
    public void Submit()
    {
        name     = name.Trim();
        email    = email.Trim();
        password = password.Trim();
        confirm  = confirm.Trim();

        if (name.Length == 0)
        {
//			mainObject.GetComponent<Main>().CreateMessageBox("Display Name Required");
            GUI.FocusControl("name_field");
        }
        else if (email.Length == 0)
        {
//			mainObject.GetComponent<Main>().CreateMessageBox("Email Required");
            GUI.FocusControl("email_field");
        }
        else if (!CheckEmail(email))
        {
//			mainObject.GetComponent<Main>().CreateMessageBox("Invalid Email");
            GUI.FocusControl("email_field");
        }
        else if (password.Length == 0)
        {
//			mainObject.GetComponent<Main>().CreateMessageBox("Password Required");
            GUI.FocusControl("password_field");
        }
        else if (!password.Equals(confirm))
        {
//			mainObject.GetComponent<Main>().CreateMessageBox("Passwords do not match");
            GUI.FocusControl("confirm_field");
        }
        else
        {
            NetworkManager.Send(
                RegisterProtocol.Prepare(fname, lname, email, password, name, color),
                ProcessRegister
                );
        }
    }