/*****************************************************************************//** * @brief This function sets up the PUT response to the remote server after * the GET response is returned. * * @param status. The status of the query. * @param msg. Result code to be sent back to the remote server. * @param id. id of action * @return nothing. * @author Neal Shurmantine * @version * 02/09/2016 Created. *******************************************************************************/ uint32_t RAS_SendActionResponse(eActionStatus status, eActionMessageId msg, uint32_t action_id) { REST_CLIENT_QUERY_STRUCT_PTR p_query = (REST_CLIENT_QUERY_STRUCT_PTR)OS_GetMemBlock(sizeof(REST_CLIENT_QUERY_STRUCT)); char *clientJSON = (char*)OS_GetMemBlock(MAX_JSON_LENGTH); LoadDefaultClientData(p_query, &hunterDouglasRASServerSSLParameters,HTTPSRV_REQ_PUT,put_action_response_return); snprintf(clientJSON,MAX_JSON_LENGTH, HUB_ACTION_JSON_RESPONSE, status, msg); snprintf(p_query->resource,MAX_RESOURCE_NAME_LENGTH, HUB_ACTION_PUT_RESOURCE, RMT_GetAPIVersion(), action_id); p_query->json = clientJSON; p_query->socket_options.connection_timeout = 18 * SEC_IN_MS; MakeAuthorizationString(p_query->authorize,false); ConnectToServer(p_query); if (p_query->connection.socket) { if (PutResource(p_query,false)) { p_query->callback(p_query); } DisconnectFromServer(p_query); } OS_ReleaseMemBlock((char*)clientJSON); OS_ReleaseMemBlock((void*)p_query); return 1; }
// virtual void ProtocolModuleTaiga::Update(f64 frametime) { { PROFILE(ProtocolModuleTaiga_Update); if (loginWorker_.IsReady() && loginWorker_.GetState() == ProtocolUtilities::Connection::STATE_XMLRPC_REPLY_RECEIVED) { // XML-RPC reply received; get the login parameters and signal that we're ready to // establish an UDP connection. clientParameters_ = loginWorker_.GetClientParameters(); loginWorker_.SetConnectionState(ProtocolUtilities::Connection::STATE_INIT_UDP); } else if (loginWorker_.GetState() == ProtocolUtilities::Connection::STATE_LOGIN_FAILED) { eventManager_->SendEvent(networkStateEventCategory_, ProtocolUtilities::Events::EVENT_CONNECTION_FAILED, 0); loginWorker_.SetConnectionState(ProtocolUtilities::Connection::STATE_DISCONNECTED); } if (connected_) { try { networkManager_->ProcessMessages(); } catch(Poco::Net::NetException &e) { LogError(e.what()); LogError("Network error occured. Closing server connection."); DisconnectFromServer(); } } } RESETPROFILER; }
void child_die(int save) { if (save) savealldb(); killallfakes(); unloadallmod(); DisconnectFromServer(); flush_sendq(); CloseAllSock(); unlink("child.pid"); child_clean(); }
// virtual void ProtocolModuleOpenSim::Uninitialize() { thread_.join(); if (connected_) DisconnectFromServer(); if (networkManager_) networkManager_->UnregisterNetworkListener((ProtocolUtilities::INetMessageListener *)this); eventManager_.reset(); }
void KeyboardClicked() { if(gamestate == 0) //Hotkeys in the "mainmenu" { if(keyboard->isKeyPressed("ESC") == true) { play = false; //Exit the game loop and program } if(keyboard->isKeyPressed("S") == true || keyboard->isKeyPressed("ENTER") == true) //Start game { ConnectToServer(); gamestate = 1; } if(keyboard->isKeyPressed("E") == true) { play = false; //Exiting the game loop and program } if(keyboard->isKeyPressed("ALT") == true && keyboard->isKeyPressed("F4") == true) { play = false; //Exiting the program } } else { if(gamestate == 1) //We are playing, hotkeys for moving (WASD space enter) { if(keyboard->isKeyPressed("F10") == true) { gamestate = 2; //Viewing menu while playing } } else {//We are in game, but the "Menu" (quit/continue) is showing if(keyboard->isKeyPressed("C") ==true) { gamestate = 1; //Back to the game, menu is not drawn } else { //Quit Game, back to main menu if(keyboard->isKeyPressed("Q") == true) { DisconnectFromServer(); client->Exit(); gamestate = 0; SERVERRESPONSE = false; } } } } }
void ProtocolModuleTaiga::UnregisterNetworkEvents() { if (connected_) DisconnectFromServer(); if (networkManager_) { networkManager_->UnregisterNetworkListener(this); networkManager_.reset(); } LogInfo("Networking unregistered."); }
// virtual void ProtocolModuleTaiga::Uninitialize() { thread_.join(); if (connected_) DisconnectFromServer(); if (networkManager_) { networkManager_->UnregisterNetworkListener(this); networkManager_.reset(); } }
void child_restart(int save) { if (save) savealldb(); killallfakes(); unloadallmod(); DisconnectFromServer(); flush_sendq(); CloseAllSock(); char buf[1024]; char dir[1024]; getcwd(buf,1024); snprintf(dir,1024,"%s/child",buf); system(dir); child_clean(); }
CheckerArea::CheckerArea(QWidget *parent) : QWidget(parent), ui(new Ui::CheckerArea) { ui->setupUi(this); setFocusPolicy(Qt::TabFocus); board = nullptr; field1 = QColor(0,0,0); field2 = QColor(255,255,255); pawn1 = QColor(0,0,255); pawn2 = QColor(255,0,0); cursorState = Free; disconnectTimer = new QTimer(); disconnectTimer->setInterval(10); clearMessageTimer = new QTimer(); connect(clearMessageTimer,SIGNAL(timeout()), this, SLOT(ClearStateMessage())); displayedBoard = 0; waitForIATimer = new QTimer(); waitForIATimer->setInterval(50); connect(waitForIATimer,SIGNAL(timeout()), this, SLOT(CheckStatus())); agentTCP = new TCPHandler(this); connect(agentTCP, SIGNAL(ServerStateReceived(ServerState)), this, SLOT(GetServerState(ServerState))); connect(agentTCP, SIGNAL(StateConnecting(const QString)), this, SLOT(StateConnecting(const QString))); connect(agentTCP, SIGNAL(StateRegister(const QString)), this, SLOT(StateRegister(const QString))); connect(agentTCP, SIGNAL(StateUpdating(const QString)), this, SLOT(StateUpdating(const QString))); connect(agentTCP, SIGNAL(StateUpdated(QString)), this, SLOT(StateUpdated(const QString))); connect(agentTCP, SIGNAL(FailedSendJob(const QString)), this, SLOT(ProblemWithSendingJob(QString))); connect(disconnectTimer, SIGNAL(timeout()), this, SLOT(DisconnectFromServer())); connect(this, SIGNAL(Disconnect()), agentTCP, SLOT(Disconnect())); agentTCP->Start(); }
/*****************************************************************************//** * @brief This function is called to start the whole process of contacting the * remote connect server and getting an action update * * @param none * @return next time to check for an update in seconds. * @author Neal Shurmantine * @version * 02/24/2015 Created. *******************************************************************************/ uint32_t RAS_CheckActionUpdate(void) { char pin[5]; int n; getRemoteConnectPin(pin); pin[4] = 0; for (n = 0; n < 4; ++n) { if ( (pin[n] < '0') || (pin[n] > '9') ) { return REMOTE_CONNECT_DEFAULT_CHECK_TIME; } } RAS_RemoteConnectCheckTime = REMOTE_CONNECT_DEFAULT_CHECK_TIME; REST_CLIENT_QUERY_STRUCT_PTR p_query = (REST_CLIENT_QUERY_STRUCT_PTR)OS_GetMemBlock(sizeof(REST_CLIENT_QUERY_STRUCT)); LoadDefaultClientData(p_query, &hunterDouglasRASServerSSLParameters,HTTPSRV_REQ_GET,action_update_get_return); p_query->socket_options.connection_timeout = 18 * SEC_IN_MS; /* p_query->socket_options.send_timeout = 5 * SEC_IN_MS; p_query->socket_options.rto = 2 * SEC_IN_MS; p_query->socket_options.maxrto = 5 * SEC_IN_MS; */ MakeAuthorizationString(p_query->authorize,false); snprintf(p_query->resource,MAX_RESOURCE_NAME_LENGTH, HUB_ACTION_GET_RESOURCE, RMT_GetAPIVersion()); ConnectToServer(p_query); if (p_query->connection.socket) { if (GetResource(p_query)) { p_query->callback(p_query); } if (GetResponseStatus()->code == 401) { printf("Dissociate this hub!\n"); clearRegistrationData(); } DisconnectFromServer(p_query); } RAS_Status = p_query->status; OS_ReleaseMemBlock((void*)p_query); return RAS_RemoteConnectCheckTime; }
void MouseClicked() { if(gamestate == 0) //Main Menu { if(btnExit->isPressed() == true) { play = false; //Exit the game loop and program } if(btnStart->isPressed() == true) { ConnectToServer(); gamestate = 1; } } else { if(gamestate == 2) { if(btnQuitGame->isPressed() == true) { DisconnectFromServer(); //Say goodbye to the server client->Exit(); //Exit server gamestate = 0; //Back to main menu SERVERRESPONSE = false; //Need new response from server } if(btnCancel->isPressed() == true) { gamestate = 1; //Back to the game } } } //There is no gamestate on the server. /*switch(gamestate) { case 0: //We are in the main menu break; case 1: break; //We are in the game, playing, shooting, moving case 2: break; //We are in a menu, Exit/Continue playing }*/ }
/////////////////////////////////////////////////////////////////////////////////////////////// // Verbindung zur GeoEdit-Erweiterung über deren Interface IEditExtensionSite herstellen STDMETHODIMP CNewArea::SetEditExtensionSite (IEditExtensionSite* pIEdExSite) { try { if (pIEdExSite != NULL) { WUnknown wISite; // Verbindung zu TRiAS über Interface ITriasExtension herstellen THROW_FAILED_HRESULT (pIEdExSite->GetXtensionSite (wISite.ppi())); THROW_FAILED_HRESULT (pIEdExSite->CreateInterfaceTO (m_wTopObjs.ppi())); if (wISite.IsValid()) // in TRiAS reinhängen { if (m_dwCookieN != 0L || m_dwCookieSN != 0L) // anmelden _com_issue_error (E_UNEXPECTED); // darf noch nicht angemeldet sein m_Site = wISite; // throws_com_error THROW_FAILED_HRESULT (AtlAdvise (m_Site, (ITRiASNotificationSink*)this, IID_ITRiASNotificationSink, &m_dwCookieN)); THROW_FAILED_HRESULT (AtlAdvise (m_Site, (ITRiASSysNotificationSink*)this, IID_ITRiASSysNotificationSink, &m_dwCookieSN)); } m_wEdExSite = pIEdExSite; m_wEdExSite->SetCursor (CURSFORM_CROSS, TRUE); THROW_FAILED_HRESULT (m_wTopObjs->GetEnumTopicalObjectsGeometry (TRUE, m_wAllTObjs.ppi())); m_wTopObjs->SetMarkVis (true); // Stützpunkte der ausgewählten Objekte sollen // markiert werden WEnumObjektGeometrie wGrabObjs (CLSID_EnumObjektGeometrie); m_wGrabObjs = wGrabObjs; } else { if (m_wObj.IsValid()) { int iActTool = DEX_GetActiveTool(); // wenn NewArea "richtig" verlassen wird (also nicht bloß zum Parken), dann das // aktuell editierte (temporäre) Objekt wieder aus den ausgewählten Objekten // herausnehmen if (ID_TOOL_DESIGN != iActTool) { Rectangle Rec = GetDeleteRectangle (m_wObj, m_wTopObjs, m_wRestrictCursor, m_LastPt); DEX_RePaintRectWait (Rec); // OHNE nachfolgendes Update() !!! m_wTopObjs->DeleteTopicalObjectGeometry (m_wObj); m_wObj.Assign (NULL); } // NewArea wird bloß zum Parken verlassen; dann hier die letzte Strecke, die zum // DesignTool führt, zu löschen else if (m_wDragObj.IsValid()) { BOOL bTopIsPaint; // wird in CTopicalObjects der Hintergrund gezeichnet? m_wTopObjs->IsPaint (&bTopIsPaint); _ASSERTE (m_bIsPaint == false && bTopIsPaint == false); m_wDragObj->DeleteLastSituation (m_bIsPaint || bTopIsPaint); m_bWithDel = false; } } // Stützpunktmarkierungen der ausgewählten Objekte sollen gelöscht werden m_wTopObjs->SetMarkVis (false); // Cursor wieder auf die Standard-Form "PFEIL" zurücksetzen m_wEdExSite->SetCursor (CURSFORM_PFEIL, TRUE); if (m_dwCookieN != 0L || m_dwCookieSN != 0L) // abmelden THROW_FAILED_HRESULT (DisconnectFromServer()); // gibt uns u.u. frei if (m_wRestrictCursor.IsValid()) { m_wRestrictCursor->UnDraw(); m_wRestrictCursor.Assign (NULL); } m_wRestrLine1.Assign (NULL); m_wRestrLine2.Assign (NULL); m_wTopObjs.Assign (NULL); m_wEdExSite.Assign (NULL); m_bMessBox = false; // keine MessageBox angezeigt } } catch (_com_error& e) { return _COM_ERROR (e); } return S_OK; } // SetEditExtensionSite