std::string ChatMessage::getMsgString() { unsigned short usMsg[4]; usMsg[0] = MT_ChatMessage; usMsg[1] = getBodyLength(); usMsg[2] = ((unsigned short*)&m_uiUserID)[0]; // TODO: this seems unnessecary usMsg[3] = ((unsigned short*)&m_uiUserID)[1]; std::string strHeader( (char*)usMsg, 8 ); return strHeader+m_strMessage; }
const int EvaFTSynPacket::parseHeader(unsigned char *buf) { int pos = 0; if(buf[pos++] != m_StartTag) return -1; unsigned short tmp2 = EvaUtil::read16(buf + pos); pos+=2; if(tmp2 != getBodyLength()) return -1; m_Version = EvaUtil::read16(buf + pos); pos+=2; m_Sequence = EvaUtil::read16(buf + pos); pos+=2; m_Id = EvaUtil::read32(buf + pos); pos+=4; m_Command = EvaUtil::read16(buf + pos); pos+=2; return pos; }
const int EvaFTAgentPacket::parseHeader(unsigned char *buf) { if(getTag() != QQ_FILE_AGENT_PACKET_TAG || getTail() != QQ_FILE_AGENT_PACKET_TAIL) return -1; int pos = 0; m_Version = EvaUtil::read16(buf + pos); pos+=2; unsigned short tmp2 = EvaUtil::read16(buf + pos); pos+=2; if(tmp2 != getBodyLength()) return -1; m_Command = EvaUtil::read16(buf + pos); pos+=2; m_Sequence = EvaUtil::read16(buf + pos); pos+=2; m_Id = EvaUtil::read32(buf + pos); pos+=4; pos+=8; // 8 unknown bytes if(m_Command != QQ_FILE_AGENT_CMD_CREATE){ m_Session = EvaUtil::read32(buf + pos); pos+=4; } return pos; }