Exemplo n.º 1
0
    private void TcpLoginMsgButtonClick()
    {
        Login login = new Login();

        login.UserName = "******";
        login.PassWord = "******";

        byte[] bodys = login.ToByteArray();

        string strs = "";

        for (int i = 0; i < bodys.Length; i++)
        {
            strs = strs + " " + bodys[i];
        }
        int bodycount = bodys.Length;

        byte[] bodycountbytes   = BitConverter.GetBytes(bodycount);
        byte[] headbackMsgbytes = BitConverter.GetBytes((ushort)TCPEvent.TcpBackLoginMsg);

        NetMsgBase ba  = new NetMsgBase(FrameTools.CombomBinaryArray(bodycountbytes, FrameTools.CombomBinaryArray(headbackMsgbytes, bodys)));
        TCPMsg     msg = new TCPMsg((ushort)TCPEvent.TcpSendLoginMsg, ba);

        SendMsg(msg);
    }
Exemplo n.º 2
0
    private void TcpSendMsgButtonClick()
    {
        string body = "body content = asdfasdf";

        byte[] data      = Encoding.Default.GetBytes(body);
        int    bodycount = body.Length;

        byte[] bodycountbytes   = BitConverter.GetBytes(bodycount);
        byte[] headbackMsgbytes = BitConverter.GetBytes((ushort)TCPEvent.TcpSendMsgBack);

        NetMsgBase ba  = new NetMsgBase(FrameTools.CombomBinaryArray(bodycountbytes, FrameTools.CombomBinaryArray(headbackMsgbytes, data)));
        TCPMsg     msg = new TCPMsg((ushort)TCPEvent.TcpSendMsg, ba);

        SendMsg(msg);
    }