Exemplo n.º 1
0
        ////////////////////////////////////////////////////////////////////////////////
        ////////////////////////////////////////////////////////////////////////////////
        bool DoGTLoginReq(LPSocker socker)
        {
            bool          result = false;
            C2T_LOGIN_REQ msg    = null;

            msg = new C2T_LOGIN_REQ();
            if (LOG_ERROR(msg != null))
            {
                goto Exit0;
            }
            msg.MsgId   = (UInt16)C2T_MESSAGE_ID.c2t_login_req;
            msg.byValue = 1;
            msg.wValue  = 2;
            msg.dwValue = 3;
            msg.qwValue = 4;
            msg.sValue  = "I'm client, i want to login !";

            result = m_SendMessageSerializer.Init(null, 0, null, 0);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = msg.Serialize(m_SendMessageSerializer);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = socker.Send(m_SendMessageSerializer.GetSerializeBuf(), 0, m_SendMessageSerializer.GetSerializeSize());
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = m_SendMessageSerializer.UnInit();
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            return(true);

Exit0:

            result = m_SendMessageSerializer.UnInit();
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            return(false);
        }
Exemplo n.º 2
0
        public virtual bool Serialize(ILPMessageSerializer messageSerializer)
        {
            bool   result = false;
            UInt16 size   = 0;

            byte[] buf = null;

            if (LOG_ERROR(messageSerializer != null))
            {
                goto Exit0;
            }

            // # begin serialize field #

            result = messageSerializer.WriteUInt16(MsgId);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteUInt16(4);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            // # end #

            buf = messageSerializer.GetSerializeBuf();
            if (LOG_ERROR(buf != null))
            {
                goto Exit0;
            }

            if (LOG_ERROR(messageSerializer.GetSerializeSize() <= LPMessageHeader.MAX_PACKET_LEN))
            {
                goto Exit0;
            }

            size = (UInt16)messageSerializer.GetSerializeSize();
            if (LOG_ERROR(size >= 4))
            {
                goto Exit0;
            }

            buf[2] = (Byte)(size >> 8);
            buf[3] = (Byte)((size << 8) >> 8);

            return(true);

Exit0:
            return(false);
        }
Exemplo n.º 3
0
        public override bool Serialize(ILPMessageSerializer messageSerializer)
        {
            bool   result = false;
            UInt16 size   = 0;

            byte[] buf = null;

            if (LOG_ERROR(messageSerializer != null))
            {
                goto Exit0;
            }

            // # begin serialize field #

            result = base.Serialize(messageSerializer);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteUInt8(byValue);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteUInt16(wValue);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteUInt32(dwValue);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteUInt64(qwValue);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            result = messageSerializer.WriteString(sValue);
            if (LOG_ERROR(result))
            {
                goto Exit0;
            }

            // # end #

            buf = messageSerializer.GetSerializeBuf();
            if (LOG_ERROR(buf != null))
            {
                goto Exit0;
            }

            if (LOG_ERROR(messageSerializer.GetSerializeSize() <= LPMessageHeader.MAX_PACKET_LEN))
            {
                goto Exit0;
            }

            size = (UInt16)messageSerializer.GetSerializeSize();
            if (LOG_ERROR(size >= 4))
            {
                goto Exit0;
            }

            buf[2] = (Byte)(size >> 8);
            buf[3] = (Byte)((size << 8) >> 8);

            return(true);

Exit0:
            return(false);
        }