OCEntityHandlerResult OCEntityHandlerFanCb(OCEntityHandlerFlag flag, OCEntityHandlerRequest * ehRequest) { OCEntityHandlerResult ret = OC_EH_OK; OCEntityHandlerResponse response; char payload[MAX_RESPONSE_LENGTH] = {0}; OC_LOG_V(INFO, TAG, "Callback for Fan"); PrintReceivedMsgInfo(flag, ehRequest ); if(ehRequest && flag == OC_REQUEST_FLAG) { if(OC_REST_GET == ehRequest->method) { ret = HandleCallback(ehRequest, rspGetFanDefault, rspFailureFan, payload, sizeof(payload)); } else if(OC_REST_PUT == ehRequest->method) { ret = HandleCallback(ehRequest, rspPutFanDefault, rspFailureFan, payload, sizeof(payload)); } else { OC_LOG_V (INFO, TAG, "Received unsupported method %d from client", ehRequest->method); ret = OC_EH_ERROR; } if (ret == OC_EH_OK) { // Format the response. Note this requires some info about the request response.requestHandle = ehRequest->requestHandle; response.resourceHandle = ehRequest->resource; response.ehResult = ret; response.payload = (unsigned char *)payload; response.payloadSize = strlen(payload); response.numSendVendorSpecificHeaderOptions = 0; memset(response.sendVendorSpecificHeaderOptions, 0, sizeof response.sendVendorSpecificHeaderOptions); memset(response.resourceUri, 0, sizeof response.resourceUri); // Indicate that response is NOT in a persistent buffer response.persistentBufferFlag = 0; // Send the response if (OCDoResponse(&response) != OC_STACK_OK) { OC_LOG(ERROR, TAG, "Error sending response"); ret = OC_EH_ERROR; } } } else if (ehRequest && flag == OC_OBSERVE_FLAG) { gLightUnderObservation = 1; } return ret; }
void RequestBaseTask::onFail(long requestId, string url) { // Handle in sub class mbFinishOK = HandleCallback(url, false, NULL, 0); // Send message to main thread OnTaskFinish(); }
/* IHttpRequestManagerCallback */ void RequestBaseTask::onSuccess(long requestId, string url, const char* buf, int size) { // Handle in sub class mbFinishOK = HandleCallback(url, true, buf, size); // Send message to main thread OnTaskFinish(); }
uint32 CScreenTeam::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2) { if (dwCommand == CMD_OK) { HandleCallback(dwParam1,dwParam2); return 1; } switch(dwCommand) { case CMD_EDIT_NAME: { //show edit box here MBCreate mb; mb.eType = LTMB_EDIT; mb.pFn = EditNameCallBack; // mb.eInput = CLTGUIEditCtrl::kInputAlphaNumeric; mb.pString = m_sTeamName.c_str(); mb.nMaxChars = MAX_PLAYER_NAME-1; g_pInterfaceMgr->ShowMessageBox(IDS_TEAM_NAME,&mb); } break; case CMD_LEFT: { PrevModel(); } break; case CMD_RIGHT: { NextModel(); } break; default: return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2); } return 1; };
uint32 CScreenJoin::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2) { switch(dwCommand) { case CMD_CANCEL : { ChangeState(eState_Waiting); break; } case CMD_OK: { return HandleCallback(dwParam1,dwParam2); } case CMD_SEARCH : { FindServers(); break; } case CMD_EDIT_CDKEY : { ChangeState(eState_ChangeCDKey); break; } case CMD_JOIN: { if (dwParam1 >= m_cServerList.size()) return 0; m_nSelectedServer = dwParam1; if (g_pGameClientShell->IsWorldLoaded()) { if (IsCurrentGame(m_cServerList[m_nSelectedServer].m_sAddress.c_str())) { HLOCALOBJ hPlayerObj = g_pLTClient->GetClientObject(); if (g_pGameClientShell->IsWorldLoaded() && hPlayerObj) { g_pInterfaceMgr->ChangeState(GS_PLAYING); } } else { MBCreate mb; mb.eType = LTMB_YESNO; mb.pFn = JoinLanConfirmationCallback; g_pInterfaceMgr->ShowMessageBox(IDS_ENDCURRENTGAME,&mb); } } else { JoinCurGame(); } break; } default: return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2); } return 1; }
/*----------------------------------------------------------------------------*/ inline int ProcessInIPv4Packet(mtcp_manager_t mtcp, struct pkt_ctx *pctx) { bool release = false; int ret; struct mon_listener *walk; /* check and process IPv4 packets */ struct iphdr* iph = (struct iphdr *)((char *)pctx->p.ethh + sizeof(struct ethhdr)); int ip_len = ntohs(iph->tot_len); /* drop the packet shorter than ip header */ if (ip_len < sizeof(struct iphdr)) { ret = ERROR; goto __return; } if (ip_fast_csum(iph, iph->ihl)) { ret = ERROR; goto __return; } if (iph->version != IPVERSION ) { release = true; ret = FALSE; goto __return; } FillInPacketIPContext(pctx, iph, ip_len); switch (iph->protocol) { case IPPROTO_TCP: return ProcessInTCPPacket(mtcp, pctx); case IPPROTO_ICMP: if (ProcessICMPPacket(mtcp, pctx)) return TRUE; default: /* forward other protocols without any processing */ if (!mtcp->num_msp || !pctx->forward) release = true; else ForwardIPPacket(mtcp, pctx); ret = FALSE; goto __return; } __return: /* callback for monitor raw socket */ TAILQ_FOREACH(walk, &mtcp->monitors, link) if (walk->socket->socktype == MOS_SOCK_MONITOR_RAW) HandleCallback(mtcp, MOS_NULL, walk->socket, MOS_SIDE_BOTH, pctx, MOS_ON_PKT_IN); if (release && mtcp->iom->release_pkt) mtcp->iom->release_pkt(mtcp->ctx, pctx->in_ifidx, (unsigned char *)pctx->p.ethh, pctx->p.eth_len); return ret; }
uint32 CScreenMulti::OnCommand(uint32 dwCommand, uint32 dwParam1, uint32 dwParam2) { if (m_eCurState == eState_Startup || m_eCurState == eState_ValidateCDKey) return 0; switch(dwCommand) { case CMD_UPDATE: { LaunchSierraUp(); } break; case CMD_OK: { return HandleCallback(dwParam1,dwParam2); } break; case CMD_PLAYER: { m_pScreenMgr->SetCurrentScreen(SCREEN_ID_PLAYER); break; } case CMD_JOIN: { if (g_bLAN) { m_pScreenMgr->SetCurrentScreen(SCREEN_ID_JOIN_LAN); } else { if (m_eCurState == eState_NoCDKey) { MBCreate mb; g_pInterfaceMgr->ShowMessageBox(IDS_CDKEY_INVALID,&mb); return 0; } m_pScreenMgr->SetCurrentScreen(SCREEN_ID_JOIN); } break; } case CMD_HOST: { m_pScreenMgr->SetCurrentScreen(SCREEN_ID_HOST); break; } case CMD_EDIT_CDKEY : { ChangeCDKey(); break; } default: return CBaseScreen::OnCommand(dwCommand,dwParam1,dwParam2); } return 1; };