70 lines
1.7 KiB
C++
70 lines
1.7 KiB
C++
#include "PublicNoticMission.h"
|
|
|
|
PublicNoticMission::PublicNoticMission()
|
|
{
|
|
mIGPKefuMissionSink = 0;
|
|
}
|
|
|
|
// ÉèÖûص÷½Ó¿Ú
|
|
void PublicNoticMission::setMissionSink(IPublicNoticMissionSink* pIGPKefuMissionSink)
|
|
{
|
|
mIGPKefuMissionSink = pIGPKefuMissionSink;
|
|
}
|
|
|
|
void PublicNoticMission::PublicNotice(std::string kKey)
|
|
{
|
|
if (isAlive())
|
|
{
|
|
cocos2d::log("PublicNoticMission::PublicNotice isAlive");
|
|
|
|
return;
|
|
}
|
|
m_kKeyName = kKey;
|
|
start();
|
|
}
|
|
|
|
void PublicNoticMission::onEventTCPSocketLink()
|
|
{
|
|
CMD_GP_QueryNotice kNetInfo;
|
|
strncpy(kNetInfo.szKeyName,m_kKeyName.c_str(),countarray(kNetInfo.szKeyName));
|
|
//·¢ËÍÊý¾Ý
|
|
send(MDM_GP_USER_SERVICE,SUB_GP_QUERY_PUBLIC_NOTICE, &kNetInfo,sizeof(kNetInfo));
|
|
}
|
|
|
|
void PublicNoticMission::onEventTCPSocketShut()
|
|
{
|
|
cocos2d::log("CGPKefuMission::onEventTCPSocketShut\n");
|
|
}
|
|
|
|
void PublicNoticMission::onEventTCPSocketError(int errorCode)
|
|
{
|
|
cocos2d::log("CGPKefuMission::onEventTCPSocketError code[%d]\n", errorCode);
|
|
}
|
|
|
|
bool PublicNoticMission::onEventTCPSocketRead(int main, int sub, void* data, int size)
|
|
{
|
|
cocos2d::log("CGPKefuMission::onEventTCPSocketRead main:%d sub:%d size:%d\n", main, sub, size);
|
|
stop();
|
|
if (SUB_GP_PUBLIC_NOTICE == sub)
|
|
{
|
|
CMD_GP_PublicNotice* pNetInfo = (CMD_GP_PublicNotice*)data;
|
|
if (mIGPKefuMissionSink)
|
|
{
|
|
mIGPKefuMissionSink->onGPPublicNoticeResult(m_kKeyName,pNetInfo->lResultCode,pNetInfo->szDescribeString);
|
|
}
|
|
return true;
|
|
}
|
|
if (SUB_GP_OPERATE_FAILURE == sub)
|
|
{
|
|
CMD_GP_OperateFailure* pNetInfo = (CMD_GP_OperateFailure*)data;
|
|
if (mIGPKefuMissionSink)
|
|
{
|
|
mIGPKefuMissionSink->onGPPublicNoticeResult(m_kKeyName,pNetInfo->lResultCode,pNetInfo->szDescribeString);
|
|
}
|
|
return true;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|