XnStatus XnSensorClient::GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnChar* strValue) { XnStatus nRetVal = XN_STATUS_OK; // check if we have a local copy nRetVal = XnStreamReaderDevice::GetProperty(ModuleName, PropertyName, strValue); if (nRetVal == XN_STATUS_DEVICE_PROPERTY_DONT_EXIST) { // get from server (virtual property?) xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Getting property %s.%s from server...", ModuleName, PropertyName); XnSensorServerMessageGetPropertyRequest request; strcpy(request.strModuleName, ModuleName); strcpy(request.strPropertyName, PropertyName); nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY, &request, sizeof(request)); XN_IS_STATUS_OK(nRetVal); // wait for reply nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GET_STRING_PROPERTY); XN_IS_STATUS_OK(nRetVal); strcpy(strValue, (const XnChar*)m_LastReply.pData); } XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
int CWorkerThread::Call(unsigned dwParam, unsigned timeout, bool fBoostPriority, WaitFunc_t pfnWait) { AssertMsg(!m_EventSend.Check(), "Cannot perform call if there's an existing call pending" ); AUTO_LOCK( m_Lock ); if (!IsAlive()) return WTCR_FAIL; int iInitialPriority = 0; if (fBoostPriority) { iInitialPriority = BoostPriority(); } // set the parameter, signal the worker thread, wait for the completion to be signaled m_Param = dwParam; m_EventComplete.Reset(); m_EventSend.Set(); WaitForReply( timeout, pfnWait ); if (fBoostPriority) SetPriority(iInitialPriority); return m_ReturnVal; }
void CScriptDebugger::GetBreakPointsFromIde() { CMailSlotMsg msg; msg.w_int(DMSG_GET_BREAKPOINTS); SendMessageToIde(msg); WaitForReply(false); }
int gxsSMTPClient::RecvResponse(char *buf, int bytes, const char *response) // Blocking receive function used to read a reply from an SMTP server // following a command. If the specified response is not received within // the timeout period this function will return false to indicate an error. // Returns true if successful. { bytes_read = 0; // Reset the byte counter int num_read = 0; // Actual number of bytes read int num_req = (int)bytes; // Number of bytes requested char *p = buf; // Pointer to the buffer int len = 3; while(bytes_read < bytes) { // Loop until the buffer is full if(!WaitForReply()) { socket_error = gxSOCKET_REQUEST_TIMEOUT; if(bytes_read >= 0) buf[bytes_read] = 0; return 0; } if((num_read = recv(gxsocket, p, num_req-bytes_read, 0)) > 0) { bytes_read += num_read; // Increment the byte counter p += num_read; // Move the buffer pointer for the next read if(buf[bytes_read-1] == '\n') { // We received the entire reply line buf[bytes_read] = 0; // NULL terminate the reply if(bytes_read > len) { // Look for numeric response code if(strncmp(response, buf, len) == 0) { return 1; // Found matching numeric reply code } else { // Server replied with an error socket_error = gxSOCKET_SMTP_ERROR; return 0; } } else { // Invalid reply code socket_error = gxSOCKET_SMTP_ERROR; return 0; } } } if(num_read == 0) { if(bytes_read >= 0) buf[bytes_read] = 0; socket_error = gxSOCKET_DISCONNECTED_ERROR; return 0; // An error occurred during the read } if(num_read < 0) { if(bytes_read >= 0) buf[bytes_read] = 0; socket_error = gxSOCKET_RECEIVE_ERROR; return 0; // An error occurred during the read } } // The receieve buffer is full - buffer overflow socket_error = gxSOCKET_BUFOVER_ERROR; if(bytes_read >= 0) buf[bytes_read] = 0; return 0; }
XnStatus XnSensorClient::SendBye() { xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Sending Bye"); XnStatus nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_BYE, NULL, 0); XN_IS_STATUS_OK(nRetVal); // wait for reply nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_BYE); XN_IS_STATUS_OK(nRetVal); return XN_STATUS_OK; }
XnStatus XnSensorClient::BatchConfig(const XnPropertySet* pChangeSet) { XnStatus nRetVal = XN_STATUS_OK; xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Batch configuring server..."); nRetVal = m_pOutgoingPacker->WritePropertySet(pChangeSet); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorClient::SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& Value) { XnStatus nRetVal = XN_STATUS_OK; xnLogVerbose(XN_MASK_SENSOR_SERVER, "Setting %s.%s...", ModuleName, PropertyName); nRetVal = m_pOutgoingPacker->WriteProperty(ModuleName, PropertyName, Value); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
void CScriptDebugger::Connect(LPCSTR mslot_name) { m_bIdePresent = CheckExisting(IDE_MAIL_SLOT); ZeroMemory(m_curr_connected_mslot,sizeof(m_curr_connected_mslot)); if (Active()) { _SendMessage(DMSG_NEW_CONNECTION,0,0); CMailSlotMsg msg; msg.w_int(DMSG_GET_BREAKPOINTS); SendMessageToIde(msg); WaitForReply(false); strcat(m_curr_connected_mslot,mslot_name); } }
XnStatus XnSensorClient::LoadConfigFromFile(const XnChar* csINIFilePath, const XnChar* csSectionName) { XnStatus nRetVal = XN_STATUS_OK; XnSensorServerMessageIniFile message; strncpy(message.strFileName, csINIFilePath, XN_FILE_MAX_PATH); strncpy(message.strSectionName, csSectionName, XN_DEVICE_MAX_STRING_LENGTH); nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_INI_FILE, &message, sizeof(message)); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XBOOL XSocket::CheckSocket() { if(m_hSocket!=XNULL) { if(WaitForReply(0)>=XWAIT_OK) { XU32 data; if(Receive((char*)&data,sizeof(XU32))==0) { Close(); return XFALSE; } } } return XTRUE; }
XnStatus XnSensorClient::DestroyStream(const XnChar* StreamName) { XnStatus nRetVal = XN_STATUS_OK; xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Destroying stream %s", StreamName); // this might be called after connection was closed if (m_bConnected) { nRetVal = m_pOutgoingPacker->WriteStreamRemoved(StreamName); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); } XnStreamReaderDevice::DestroyStream(StreamName); return (XN_STATUS_OK); }
XnStatus XnSensorClient::CreateStream(const XnChar* StreamType, const XnChar* StreamName /* = NULL */, const XnPropertySet* pInitialValues /* = NULL */) { XnStatus nRetVal = XN_STATUS_OK; XN_PROPERTY_SET_CREATE_ON_STACK(props); if (pInitialValues == NULL) { pInitialValues = &props; } xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Creating stream %s (of type %s)", StreamName, StreamType); nRetVal = m_pOutgoingPacker->WriteNewStream(StreamType, StreamName, pInitialValues); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorClient::GetProperty(const XnChar* ModuleName, const XnChar* PropertyName, const XnGeneralBuffer& Value) { XnStatus nRetVal = XN_STATUS_OK; // check if we have a local copy nRetVal = XnStreamReaderDevice::GetProperty(ModuleName, PropertyName, Value); if (nRetVal == XN_STATUS_DEVICE_PROPERTY_DONT_EXIST) { // get from server (virtual property?) xnLogVerbose(XN_MASK_SENSOR_CLIENT, "Getting property %s.%s from server...", ModuleName, PropertyName); XnUInt32 nBufSize = sizeof(XnSensorServerMessageGetPropertyRequest) + Value.nDataSize; XnUChar bufValue[XN_SENSOR_SERVER_MAX_REPLY_SIZE]; XnUChar* pBuf = bufValue; XnSensorServerMessageGetPropertyRequest* pRequest = (XnSensorServerMessageGetPropertyRequest*)pBuf; XnUChar* pData = pBuf + sizeof(XnSensorServerMessageGetPropertyRequest); strcpy(pRequest->strModuleName, ModuleName); strcpy(pRequest->strPropertyName, PropertyName); pRequest->nSize = Value.nDataSize; // copy data xnOSMemCopy(pData, Value.pData, Value.nDataSize); nRetVal = m_pOutgoingPacker->WriteCustomData(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY, pBuf, nBufSize); XN_IS_STATUS_OK(nRetVal); // wait for reply nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GET_GENERAL_PROPERTY); XN_IS_STATUS_OK(nRetVal); xnOSMemCopy(Value.pData, m_LastReply.pData, m_LastReply.nDataSize); } XN_IS_STATUS_OK(nRetVal); return (XN_STATUS_OK); }
XnStatus XnSensorClient::SetProperty(const XnChar* ModuleName, const XnChar* PropertyName, XnUInt64 nValue) { XnStatus nRetVal = XN_STATUS_OK; // there are some properties we don't change on the server (they affect only this client) if (strcmp(ModuleName, XN_MODULE_NAME_DEVICE) == 0 && strcmp(PropertyName, XN_MODULE_PROPERTY_PRIMARY_STREAM) == 0) { nRetVal = XnStreamReaderDevice::SetProperty(ModuleName, PropertyName, nValue); XN_IS_STATUS_OK(nRetVal); } else { // set it on the server xnLogVerbose(XN_MASK_SENSOR_SERVER, "Setting %s.%s to %llu...", ModuleName, PropertyName, nValue); nRetVal = m_pOutgoingPacker->WriteProperty(ModuleName, PropertyName, nValue); XN_IS_STATUS_OK(nRetVal); nRetVal = WaitForReply(XN_SENSOR_SERVER_MESSAGE_GENERAL_OP_RESPOND); XN_IS_STATUS_OK(nRetVal); } return (XN_STATUS_OK); }
//--------------------------------------------------------- // // Wait for a request from the client // //--------------------------------------------------------- int CWorkerThread::WaitForReply( unsigned timeout ) { return WaitForReply( timeout, NULL ); }
LRESULT CScriptDebugger::DebugMessage(UINT nMsg, WPARAM wParam, LPARAM lParam) { CMailSlotMsg msg; switch( nMsg ) { case DMSG_NEW_CONNECTION:{ msg.w_int(DMSG_NEW_CONNECTION); SendMessageToIde(msg); }break; case DMSG_CLOSE_CONNECTION:{ msg.w_int(DMSG_CLOSE_CONNECTION); SendMessageToIde(msg); }break; case DMSG_WRITE_DEBUG:{ msg.w_int(DMSG_WRITE_DEBUG); msg.w_string((char*)wParam); SendMessageToIde(msg); }break; case DMSG_GOTO_FILELINE:{ msg.w_int(DMSG_GOTO_FILELINE); msg.w_string((char*)wParam); msg.w_int((int)lParam); SendMessageToIde(msg); }break; case DMSG_DEBUG_BREAK:{ msg.w_int(DMSG_ACTIVATE_IDE); SendMessageToIde(msg); WaitForReply(true); }break; case DMSG_CLEAR_STACKTRACE:{ m_callStack->Clear(); msg.w_int(DMSG_CLEAR_STACKTRACE); SendMessageToIde(msg); }break; case DMSG_ADD_STACKTRACE:{ m_callStack->Add(((StackTrace*)wParam)->szDesc, ((StackTrace*)wParam)->szFile, ((StackTrace*)wParam)->nLine); msg.w_int(DMSG_ADD_STACKTRACE); msg.w_buff((StackTrace*)wParam, sizeof(StackTrace) ); SendMessageToIde(msg); }break; case DMSG_GOTO_STACKTRACE_LEVEL:{ m_callStack->GotoStackTraceLevel((int)wParam); StackLevelChanged(); }break; case DMSG_CLEAR_LOCALVARIABLES:{ msg.w_int(DMSG_CLEAR_LOCALVARIABLES); SendMessageToIde(msg); }break; case DMSG_ADD_LOCALVARIABLE:{ msg.w_int(DMSG_ADD_LOCALVARIABLE); msg.w_buff((void*)wParam,sizeof(Variable)); SendMessageToIde(msg); }break; case DMSG_CLEAR_THREADS:{ msg.w_int(DMSG_CLEAR_THREADS); SendMessageToIde(msg); }break; case DMSG_ADD_THREAD:{ msg.w_int(DMSG_ADD_THREAD); msg.w_buff((void*)wParam,sizeof(SScriptThread)); SendMessageToIde(msg); }break; case DMSG_THREAD_CHANGED:{ int nThreadID = (int)wParam; DrawThreadInfo(nThreadID); }break; case DMSG_GET_VAR_TABLE:{ DrawVariableInfo((char*)wParam); }break; case DMSG_EVAL_WATCH:{ string2048 res; res[0]=0; Eval((const char*)wParam,res, sizeof(res) ); msg.w_int(DMSG_EVAL_WATCH); msg.w_string(res); msg.w_string((const char*)wParam); SendMessageToIde(msg); }break; }//case return 0; }