示例#1
0
    public void _Reg()
    {
        mainCtrl.GetSocket().Connect("127.0.0.1", 9190);
        MyUserName     = _username.text + '\0';
        MyUserNameLeng = MyUserName.Length;
        MyPassword     = _password.text + '\0';
        MyPasswordLeng = MyPassword.Length;
        int tempSendLen = (sizeof(int) * 4 + MyUserNameLeng + MyPasswordLeng);

        byte[] tempSendBuf = new byte[4096];

        Buffer.BlockCopy(BitConverter.GetBytes(tempSendLen), 0, tempSendBuf, 0, sizeof(int));
        Buffer.BlockCopy(BitConverter.GetBytes(Protocol.PT_REG_USER), 0, tempSendBuf, sizeof(int), sizeof(int));
        Buffer.BlockCopy(BitConverter.GetBytes(MyUserNameLeng), 0, tempSendBuf, sizeof(int) * 2, sizeof(int));
        Buffer.BlockCopy(Encoding.UTF8.GetBytes(MyUserName), 0, tempSendBuf, sizeof(int) * 3, MyUserNameLeng);
        Buffer.BlockCopy(BitConverter.GetBytes(MyPasswordLeng), 0, tempSendBuf, sizeof(int) * 3 + MyUserNameLeng, sizeof(int));
        Buffer.BlockCopy(Encoding.UTF8.GetBytes(MyPassword), 0, tempSendBuf, sizeof(int) * 4 + MyUserNameLeng, MyPasswordLeng);

        mainCtrl.GetSocket().Send(tempSendBuf, tempSendLen, 0);
        mainCtrl.SetUserName(MyUserName);
        mainCtrl.RecvStart();
    }