int XMsgProcesser::DecodeRecvData(const char* pData, int nLen) { SIGNALMSG smsg; MEETMSG mmsg; std::string err; std::string strmsg(pData, nLen); smsg.GetMsg(strmsg, err); if (err.length()>0) { LOG(LS_ERROR) << "parse SIGNALMSG err:" << err; return -1; } mmsg.GetMsg(smsg._scont, err); if (err.length()>0) { LOG(LS_ERROR) << "parse MEETMSG err:" << err; return -1; } switch (smsg._stype) { case SIGNALTYPE::reqlogin: case SIGNALTYPE::resplogin: DecodeLogin(smsg._stype, mmsg); break; case SIGNALTYPE::reqsndmsg: case SIGNALTYPE::respsndmsg: DecodeSndMsg(smsg._stype, mmsg); break; case SIGNALTYPE::reqgetmsg: case SIGNALTYPE::respgetmsg: DecodeGetMsg(smsg._stype, mmsg); break; case SIGNALTYPE::reqlogout: case SIGNALTYPE::resplogout: DecodeLogout(smsg._stype, mmsg); break; case SIGNALTYPE::reqkeepalive: case SIGNALTYPE::respkeepalive: DecodeKeepAlive(mmsg); break; default: LOG(LS_ERROR) << "invalid signaltype type:" << smsg._stype; break; } return nLen; }
int XMsgProcesser::DecodeRecvData(const char* pData, int nLen) { MEETMSG mmsg; std::string err; std::string strmsg(pData, nLen); mmsg.GetMsg(strmsg, err); if (err.length()>0) { LOG(LS_ERROR) << "parse MEETMSG err:" << err; return -1; } switch (mmsg._signaltype) { case SIGNALTYPE::login: DecodeLogin(mmsg); break; case SIGNALTYPE::sndmsg: DecodeSndMsg(mmsg); break; case SIGNALTYPE::getmsg: DecodeGetMsg(mmsg); break; case SIGNALTYPE::logout: DecodeLogout(mmsg); break; case SIGNALTYPE::keepalive: DecodeKeepAlive(mmsg); break; default: LOG(LS_ERROR) << "invalid signaltype type:" << mmsg._signaltype; break; } return nLen; }