Пример #1
0
        public static bool GetSendMsgPacket(ref MsgPacket packet, byte[] bytes)
        {
            if (IsCmdV1(bytes) && GetCmd(bytes) == Cmd.CMD_USER_INFO)
            {
                uint nameLen;
                nameLen = (uint)bytes[9] << 24;
                nameLen |= (uint)bytes[10] << 16;
                nameLen |= (uint)bytes[11] << 8;
                nameLen |= (uint)bytes[12];

                uint msgLen;
                msgLen = (uint)bytes[9 + nameLen + 2] << 24;
                msgLen |= (uint)bytes[10 + nameLen + 2] << 16;
                msgLen |= (uint)bytes[11 + nameLen + 2] << 8;
                msgLen |= (uint)bytes[12 + nameLen + 2];

                byte[] nameBytes = new byte[nameLen];
                Array.Copy(bytes, 14, nameBytes, 0, nameLen);
                byte[] msgBytes = new byte[msgLen];
                Array.Copy(bytes, 14 + nameLen + 2, msgBytes, 0, msgLen);

                packet.name = Encoding.Unicode.GetString(nameBytes);
                packet.msg = Encoding.Unicode.GetString(msgBytes);

                return true;
            }
            return false;
        }
Пример #2
0
 // SEND_MSGパケット生成
 public static byte[] CreateSendMsgPacket(uint num, ref MsgPacket packet)
 {
     return CreateSendMsgPacket(num, packet.name, packet.msg);
 }