Ejemplo n.º 1
0
void CCPomelo::dispatchEvent(){
    lockEventQeueue();
    CCPomeloEvent_ *event = popEvent();
    if (event) {
        CCPomeloContent_ * content = NULL;
        if (event_content.find(event->event)!=event_content.end()) {
            content = event_content[event->event];
        }
        if (content) {
            CCObject *pTarget = content->pTarget;
            SEL_CallFuncND pSelector = content->pSelector;
            if (pTarget && pSelector)
            {
                CCPomeloReponse resp;
                resp.status = event->status;
                resp.docs = event->docs;
                (pTarget->*pSelector)((CCNode *)this,&resp);
            }
        }else{
            CCLOG("dispatch event::\r\n lost %s content",event->event.c_str());
        }
        json_decref(event->docs);
        delete event;
    }
    unlockEventQeueue();
}
Ejemplo n.º 2
0
void CCPomelo::dispatchEvent()
{
    lockEventQeueue();
    CCPomeloEvent_ *event = popEvent();
    if (event)
    {
        std::map<std::string, std::function<void(Node*, void*)> >::iterator it = event_content.find(event->event);
        if (it != event_content.end())
        {
            CCPomeloReponse resp;
            resp.status = event->status;
            resp.docs = event->docs;
            (*it).second((Node*)this, &resp);
        }

        json_decref(event->docs);
        delete event;
    }
    unlockEventQeueue();
}