void Network::SendActionToAllExceptOne(const Action& a, DistantComputer* client, bool lock) const { MSG_DEBUG("network.traffic","Send action %s to all EXCEPT %s", ActionHandler::GetActionName(a.GetType()).c_str(), client->ToString().c_str()); SendAction(a, client, false, lock); }
boolean BaseObj::SendAction(const char *actionName, BaseObj *requestor) { Action *action; (void) HasAction(actionName, &action); return SendAction(action, requestor); }
// Send Messages void Network::SendActionToAll(const Action& a, bool lock) const { if (0) { if (a.GetType() == Action::ACTION_GAME_CALCULATE_FRAME) { frames++; if (frames == Action::MAX_FRAMES) { Action b(Action::ACTION_GAME_PACK_CALCULATED_FRAMES, Action::MAX_FRAMES); SendAction(b, NULL, false, lock); printf("Sending pack for %u frames\n", Action::MAX_FRAMES); frames = 0; } return; } if (frames>0 && !a.IsFrameLess()) { // This should have arrived here assert(a.GetType()!=Action::ACTION_TIME_VERIFY_SYNC || a.GetType()!=Action::ACTION_NETWORK_VERIFY_RANDOM_SYNC); // The clients must have seen all previous frames for this to occur Action b(Action::ACTION_GAME_PACK_CALCULATED_FRAMES, frames); SendAction(b, NULL, false, lock); printf("Sending pack for %u frames because of action '%s'\n", frames, ActionHandler::GetActionName(a.GetType()).c_str()); frames = 0; } if (a.GetType()==Action::ACTION_TIME_VERIFY_SYNC || a.GetType()==Action::ACTION_NETWORK_VERIFY_RANDOM_SYNC) printf("Sending %u\n", (uint)a.GetType()); } MSG_DEBUG("network.traffic", "Send action %s to all remote computers", ActionHandler::GetActionName(a.GetType()).c_str()); SendAction(a, NULL, false, lock); }
// **************************************************************************** // // Function Name: RStandaloneDocument::EndMultiUndo( ) // // Description: End a MultiUndo chain of actions // // Returns: Nothing // // Exceptions: None // // **************************************************************************** // void RStandaloneDocument::EndMultiUndo( uWORD uwUndoStringId, uWORD uwRedoStringId ) { TpsAssertIsObject( RMultiUndoManager, m_pUndoManager ); RMultiUndoManager* pMultiManager = (RMultiUndoManager*)m_pUndoManager; // First, restore the Previous undo manager m_pUndoManager = pMultiManager->GetPreviousUndoManager( ); // Create a multi-undo action iff the pMultiManager has undo actions // If an error occurs somewhere, we may have a multi undo with no actions // in which case, we don't want to do anything... if (pMultiManager->CountUndoableActions() > 0) { // Create the MultiUndo action and restore the undo manager to the previous manager RMultiUndoableAction* pAction = new RMultiUndoableAction( pMultiManager, uwUndoStringId, uwRedoStringId ); // Now Send the action to the document SendAction( pAction ); } else delete pMultiManager; }
bool MythFEXML::ProcessRequest( HttpWorkerThread *pThread, HTTPRequest *pRequest ) { if (!pRequest) return false; if (pRequest->m_sBaseUrl != m_sControlUrl) return false; VERBOSE(VB_UPNP, QString("MythFEXML::ProcessRequest: %1 : %2") .arg(pRequest->m_sMethod).arg(pRequest->m_sRawRequest)); switch(GetMethod(pRequest->m_sMethod)) { case MFEXML_GetServiceDescription: pRequest->FormatFileResponse(m_sServiceDescFileName); break; case MFEXML_GetScreenShot: GetScreenShot(pRequest); break; case MFEXML_Message: SendMessage(pRequest); break; case MFEXML_Action: SendAction(pRequest); break; case MFEXML_ActionList: GetActionList(pRequest); break; case MFEXML_ActionListTest: GetActionListTest(pRequest); break; case MFEXML_GetRemote: GetRemote(pRequest); break; default: UPnp::FormatErrorResponse(pRequest, UPnPResult_InvalidAction); } return true; }
void NetControl::FetchMsg(CNet *pRequest) { char Msg[10000],tempMsg[1000]; int ByteCount; int End=0; CStringArray *temp=new CStringArray; strcpy(Msg,""); do { strcpy(tempMsg,""); ByteCount=pRequest->Receive(tempMsg,1000); if(ByteCount>1000||ByteCount<=0) { MessageBox(GetActiveWindow(),"接受网络信息发生错误","警告信息",MB_OK); return ; } else if(ByteCount<1000&&ByteCount>0) { End=1; } tempMsg[ByteCount]=0; strcat(Msg,tempMsg); }while(End==0); /* MessageBox(GetActiveWindow(),pMsg,"网络信息",MB_OK); if(m_Isserver) SendMsg(pRequest,"收到,谢谢!");*/ CString pMsg=Msg; if(!strncmp(Msg,"2007",4)) { int k=Msg[4]-100; manager.PlayerAc=(k+1)%2; m_pView->PlayerName[k].Format("%s",pMsg.Right(pMsg.GetLength()-5)); char st[100]; sprintf(st,"2006%c%s",manager.PlayerAc+100,m_pView->PlayerName[manager.PlayerAc]); SendMsg(st); } else if(!strncmp(Msg,"2006",4)) { m_pView->PlayerName[Msg[4]-100].Format("%s",pMsg.Right(pMsg.GetLength()-5)); } else if(!strcmp(Msg,"2005")) { m_Ready[1]=true; if(m_Ready[1] && m_Ready[0]) { manager.GameStart(); m_pView->PrintAll(); } } else if(!strncmp(Msg,"2008",4)) { int x,y; x=Msg[4]-100; y=Msg[5]-100; if(Msg[6]-100==1) { if(manager.map[x][y]==manager.Game_State+1) { manager.PointCh=manager.Search(x,y); return; } else { manager.Moveto(manager.PointCh,x,y,true); manager.Updata(); m_pView->PrintAll(); return; } } else if(Msg[6]-100==2) { manager.Game_State=(manager.Game_State+1)%2; manager.Game_State+=2; MessageBox(GetActiveWindow(),"你的对手认输了","恭喜",ID_OK); m_Ready[0]=false; m_Ready[1]=false; } else if(Msg[6]-100==3) { int k; k=MessageBox(GetActiveWindow(),"对方要求和棋,您是否接受","和棋",MB_OKCANCEL); if(k==1) { SendAction(0,0,4); m_Ready[0]=false; m_Ready[1]=false; manager.Game_State=5; } else SendAction(0,0,5); } else if(Msg[6]-100==4) { MessageBox(GetActiveWindow(),"对方接受了和棋","和棋",MB_OK); manager.Game_State=5; m_Ready[0]=false; m_Ready[1]=false; } else if(Msg[6]-100==5) { MessageBox(GetActiveWindow(),"对方不愿意和棋","和棋",MB_OK); } } }
OCStackResult BuildCollectionGroupActionJSONResponse(OCMethod method/*OCEntityHandlerFlag flag*/, OCResource *resource, OCEntityHandlerRequest *ehRequest) { OCStackResult stackRet = OC_STACK_ERROR; OC_LOG(INFO, TAG, PCF("Group Action is requested.")); // if (stackRet == OC_STACK_OK) { char *doWhat = NULL; char *details = NULL; size_t bufferLength = 0; unsigned char buffer[MAX_RESPONSE_LENGTH] = { 0 }; unsigned char *bufferPtr = NULL; bufferPtr = buffer; OCResource * collResource = (OCResource *) ehRequest->resource; char *jsonResponse; ExtractKeyValueFromRequest((char *)ehRequest->reqJSONPayload, &doWhat, &details); cJSON *json; cJSON *format; if (method == OC_REST_PUT) { json = cJSON_CreateObject(); cJSON_AddStringToObject(json, "href", resource->uri); cJSON_AddItemToObject(json, "rep", format = cJSON_CreateObject()); OC_LOG(INFO, TAG, PCF("Group Action[PUT].")); if(strcmp(doWhat, "ActionSet") == 0) { OCActionSet *actionSet; BuildActionSetFromString(&actionSet, details); if(actionSet != NULL) { AddActionSet(&resource->actionsetHead, actionSet); stackRet = OC_STACK_OK; } else { stackRet = OC_STACK_ERROR; } } else if (strcmp(doWhat, "DelActionSet") == 0) { if (FindAndDeleteActionSet(&resource, details) == OC_STACK_OK) { stackRet = OC_STACK_OK; } else { stackRet = OC_STACK_ERROR; } } jsonResponse = cJSON_Print(json); cJSON_Delete(json); strcat((char *) bufferPtr, jsonResponse); bufferLength = strlen((const char *) buffer); if (bufferLength > 0) { OCEntityHandlerResponse response = { 0 }; response.ehResult = OC_EH_OK; response.payload = buffer; response.payloadSize = bufferLength + 1; response.persistentBufferFlag = 0; response.requestHandle = (OCRequestHandle) ehRequest->requestHandle; response.resourceHandle = (OCResourceHandle) collResource; stackRet = OCDoResponse(&response); } stackRet = OC_STACK_OK; } if (method == OC_REST_POST) { OC_LOG(INFO, TAG, PCF("Group Action[POST].")); OCActionSet *actionset = NULL; json = cJSON_CreateObject(); cJSON_AddStringToObject(json, "href", resource->uri); if (strcmp(doWhat, "DoAction") == 0) { if (GetActionSet(details, resource->actionsetHead, &actionset) != OC_STACK_OK) { OC_LOG(INFO, TAG, PCF("ERROR")); stackRet = OC_STACK_ERROR; } if (actionset == NULL) { OC_LOG(INFO, TAG, PCF("ERROR")); stackRet = OC_STACK_ERROR; } else { OCAction *pointerAction = actionset->head; unsigned int num = GetNumOfTargetResource(pointerAction); ((OCServerRequest *) ehRequest->requestHandle)->ehResponseHandler = HandleAggregateResponse; ((OCServerRequest *) ehRequest->requestHandle)->numResponses = num + 1; while (pointerAction != NULL) { unsigned char actionDesc[MAX_RESPONSE_LENGTH] = { 0 }; unsigned char* actionDescPtr = actionDesc; uint16_t remaining = MAX_RESPONSE_LENGTH; strncpy((char *) actionDescPtr, (const char *) OC_JSON_PREFIX, strlen((const char *) OC_JSON_PREFIX) + 1); BuildActionJSON(pointerAction, actionDescPtr, &remaining); strncat((char *) actionDescPtr, (const char *) OC_JSON_SUFFIX, strlen((const char *) OC_JSON_SUFFIX)); ClientRequstInfo *info = (ClientRequstInfo *) OCMalloc( sizeof(ClientRequstInfo)); memset(info, 0, sizeof(ClientRequstInfo)); info->collResource = resource; info->ehRequest = (OCServerRequest *) ehRequest->requestHandle; SendAction(&info->required, pointerAction->resourceUri, actionDescPtr); AddClientRequestInfo(&clientRequstList, info); pointerAction = pointerAction->next; } stackRet = OC_STACK_OK; } } else if (strcmp(doWhat, "GetActionSet") == 0) { char *plainText = NULL; OCActionSet *actionset = NULL; cJSON_AddItemToObject(json, "rep", format = cJSON_CreateObject()); GetActionSet(details, resource->actionsetHead, &actionset); if (actionset != NULL) { BuildStringFromActionSet(actionset, &plainText); if (plainText != NULL) { cJSON_AddStringToObject(format, "ActionSet", plainText); } stackRet = OC_STACK_OK; } } jsonResponse = cJSON_Print(json); cJSON_Delete(json); strcat((char *) bufferPtr, jsonResponse); bufferLength = strlen((const char *) buffer); if (bufferLength > 0) { OCEntityHandlerResponse response = { 0 }; response.ehResult = OC_EH_OK; response.payload = buffer; response.payloadSize = bufferLength + 1; response.persistentBufferFlag = 0; response.requestHandle = (OCRequestHandle) ehRequest->requestHandle; response.resourceHandle = (OCResourceHandle) collResource; stackRet = OCDoResponse(&response); } } OCFree(doWhat); OCFree(details); } return stackRet; }