Beispiel #1
0
    void ack_challenge(int err, wire obj)
    {
        a_challenge ack = (a_challenge)obj;
        string      str = user_passwd.text;

        byte[]  passwd = sha1(str);
        byte[]  hash   = hmac(passwd, Encoding.Default.GetString(ack.randomkey));
        r_login req    = new r_login();

        Debug.Log("challenge!" + Encoding.Default.GetString(ack.randomkey) +
                  ":" + BitConverter.ToString(hash));
        req.gateid = 1;
        req.user   = Encoding.Default.GetBytes(user_name.text);
        req.passwd = hash;
        NetInstance.Login.Send(req);
        return;
    }
Beispiel #2
0
    void Start()
    {
        user_name.text   = "findstr";
        user_passwd.text = "asdfg";
        //event
        create_btn.onClick.AddListener(on_create);
        login_btn.onClick.AddListener(on_login);
        //protocol
        a_create     create     = new a_create();
        a_login      login      = new a_login();
        a_challenge  challenge  = new a_challenge();
        a_login_gate login_gate = new a_login_gate();

        NetInstance.Login.Register(create, ack_create);
        NetInstance.Login.Register(challenge, ack_challenge);
        NetInstance.Login.Register(login, ack_login);
        NetInstance.Gate.Register(login_gate, ack_login_gate);
    }