本文整理汇总了C++中SPELLipcMessage类的典型用法代码示例。如果您正苦于以下问题:C++ SPELLipcMessage类的具体用法?C++ SPELLipcMessage怎么用?C++ SPELLipcMessage使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SPELLipcMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: run
//=============================================================================
// METHOD: SPELLipcIncomingRequest:run
//=============================================================================
void SPELLipcIncomingRequest::run()
{
std::string senderId = m_message->getSender();
std::string receiverId = m_message->getReceiver();
// If the request has been canceled beforehand
if (m_cancel) return;
SPELLipcMessage* response = m_listener->processRequest(m_message);
if (response && !m_cancel)
{
response->setSender(receiverId);
response->setReceiver(senderId);
// Do not set sequence number if it is already set.
// This happens when forwarding requests.
if (response->getSequence() == -1)
{
response->setSequence( m_message->getSequence() );
}
try
{
if (m_interface->isConnected())
{
SPELLipcOutput& writer = m_interface->getWriter(m_message->getKey());
writer.send(response);
m_interface->endRequest( getThreadId() );
}
}
catch(...) {};
delete response;
}
finish();
delete m_message;
}
示例2: DEBUG
//=============================================================================
// METHOD: SPELLipcMessageMailbox::retrieve
//=============================================================================
SPELLipcMessage SPELLipcMessageMailbox::retrieve( std::string id, unsigned long timeoutMsec )
{
DEBUG(NAME + "Retrieve response with id " + id)
SPELLipcMessageQueue* queue = getQueue(id);
SPELLipcMessage msg = VOID_MESSAGE;
try
{
if (timeoutMsec == 0)
{
msg = queue->pull();
}
else
{
msg = queue->pull(timeoutMsec);
}
remove(id);
}
catch( SPELLqueueTimeout& timeout )
{
//remove(id);
// Re-throw the exception
throw SPELLipcError(NAME + "Response timed out (limit " + ISTR(timeoutMsec) + " msec.)", (SPELLerrorCode) IPC_ERROR_TIMEOUT_ECODE);
}
DEBUG(NAME + "Retrieve message with id " + id + " done: " + msg.getSequenceStr());
return msg;
}
示例3: STRI
//=============================================================================
// METHOD: SPELLlistenerContext::onNewContext
//=============================================================================
void SPELLlistenerContext::onNewContext( const SPELLipcMessage& msg )
{
ContextInfo* ctxInfo;
std::string ctxName = msg.get(MessageField::FIELD_CTX_NAME);
ctxInfo = &m_openContexts[ctxName];
ctxInfo->m_key = msg.getKey();
ctxInfo->m_port = STRI(msg.get(MessageField::FIELD_CTX_PORT));
ctxInfo->m_status = MessageValue::DATA_CTX_RUNNING;
DEBUG("New context:");
DEBUG("- Name=" + ctxInfo->m_name);
DEBUG("- Key=" + ISTR(ctxInfo->m_key));
DEBUG("- Port=" + ISTR(ctxInfo->m_port));
DEBUG("- Status=" + ctxInfo->m_status);
m_waitForContextStart.set();
// Notify to other clients
SPELLipcMessage notify( msg );
notify.setId( ListenerMessages::MSG_CONTEXT_OP );
notify.setType( MSG_TYPE_ONEWAY );
notify.set( MessageField::FIELD_CTX_STATUS, MessageValue::DATA_CTX_RUNNING );
notify.setSender("LST");
notify.setReceiver("GUI");
m_gui->displace(¬ify);
// Send notification to peer if any, and if alignment is enabled
if (m_peer) m_peer->displace(msg);
}
示例4: sendRequestToClient
//=============================================================================
// METHOD: SPELLclient::
//=============================================================================
SPELLipcMessage SPELLclient::sendRequestToClient( const SPELLipcMessage& msg )
{
TICK_IN;
SPELLipcMessage result = VOID_MESSAGE;
DEBUG( NAME + "Send request to client: " + msg.dataStr() );
result = m_clientIPC.sendRequest( getClientKey(), msg, m_ipcTimeoutGuiRequestMsec );
DEBUG( NAME + "Response for request to client: " + result.dataStr() );
TICK_OUT;
return result;
}
示例5: SPELLipcMessage
//=============================================================================
// METHOD: SPELLipcMessageMailbox::cancelAll()
//=============================================================================
void SPELLipcMessageMailbox::cancelAll()
{
SPELLipcMessageQueueMap::iterator mit;
for( mit = m_queueMap.begin(); mit != m_queueMap.end(); mit++)
{
SPELLipcMessage* dummyResponse = new SPELLipcMessage("dummy");
dummyResponse->setType( MSG_TYPE_RESPONSE );
SPELLipcMessageQueue* queue = (*mit).second;
queue->push(dummyResponse);
}
}
示例6: ISTR
//=============================================================================
// METHOD: SPELLlistenerContext::startContext
//=============================================================================
SPELLipcMessage SPELLlistenerContext::startContext( const SPELLipcMessage& msg )
{
std::string cmd;
std::string name;
name = msg.get(MessageField::FIELD_CTX_NAME);
cmd = SPELLutils::getSPELL_HOME() + PATH_SEPARATOR + "bin" + PATH_SEPARATOR
+ "SPELL-Context -n " + name + " -s " + ISTR(m_port)
+ " -c " + m_configFile;
DEBUG("Opening context using command: " + cmd);
std::string identifier = "CTX_" + name;
// Will have no effect if the listener is there already
SPELLprocessManager::instance().addListener("CTX_" + name, this);
// Clear process information, in case it is there already
SPELLprocessManager::instance().clearProcess(identifier);
// Register and start the process
SPELLprocessManager::instance().startProcess("CTX_" + name, cmd);
// Notify to other clients
SPELLipcMessage notify( msg );
notify.setId( ListenerMessages::MSG_CONTEXT_OP );
notify.setType( MSG_TYPE_ONEWAY );
notify.set( MessageField::FIELD_CTX_STATUS, MessageValue::DATA_CTX_STARTING );
notify.setSender("LST");
notify.setReceiver("GUI");
m_gui->displace(¬ify);
DEBUG("Wait context " + name + " login");
m_waitForContextStart.clear();
bool timeout = m_waitForContextStart.wait(15*1000);
DEBUG("Wait context " + name + " login done: timeout " + BSTR(timeout));
if (timeout)
{
SPELLipcMessage resp = SPELLipcHelper::createErrorResponse(ContextMessages::RSP_OPEN_CTX, msg);
resp.set( MessageField::FIELD_FATAL, PythonConstants::True);
resp.set( MessageField::FIELD_ERROR, "Cannot open context " + name);
resp.set( MessageField::FIELD_REASON, "Context did not log in in time");
return resp;
}
else
{
LOG_INFO("Context running");
return SPELLipcHelper::createResponse(ContextMessages::RSP_OPEN_CTX, msg);
}
}
示例7: DEBUG
//=============================================================================
// METHOD: SPELLclientIPC::
//=============================================================================
SPELLipcMessage SPELLclientIPC::processRequest( const SPELLipcMessage& msg )
{
int clientKey = msg.getKey();
DEBUG("[CLTRCV] Received request from client: " + msg.getId());
SPELLipcMessage resp = VOID_MESSAGE;
SPELLclientInterestList* list = getClientInterestList(clientKey);
// If the message is a login message, redirect it to the client manager
if (msg.getId() == ContextMessages::REQ_GUI_LOGIN)
{
SPELLclientManager::instance().clientLogin(clientKey, msg.get( MessageField::FIELD_HOST ));
resp = SPELLipcHelper::createResponse(ContextMessages::RSP_GUI_LOGIN, msg);
}
// If the message is a logout message, redirect it to the client manager
else if (msg.getId() == ContextMessages::REQ_GUI_LOGOUT )
{
// No need to close IPC here. When the GUI receives the response,
// it will close the channel by sending EOC. There, IPC layer will
// automatically close the corresponding channel.
SPELLclientManager::instance().clientLogout(clientKey);
resp = SPELLipcHelper::createResponse(ContextMessages::RSP_GUI_LOGOUT, msg);
}
else if (list != NULL)
{
//DEBUG("[CLTRCV] Distribute client request: " + msg.getId());
resp = list->distributeRequest(msg);
//DEBUG("[CLTRCV] Got response for client request: " + msg.getId());
// Executor request additional processing (request attended by executor that need to be processed in context also)
// But only if the response is not an error
if (resp.getType() != MSG_TYPE_ERROR)
{
if (msg.getId() == ExecutorMessages::REQ_SET_CONFIG)
{
SPELLipcMessage cfgChange( msg );
cfgChange.setId( ContextMessages::MSG_EXEC_CONFIG );
cfgChange.setType( MSG_TYPE_ONEWAY );
SPELLclientManager::instance().notifyMonitoringClients(&cfgChange);
}
}
if (resp.isVoid())
{
LOG_ERROR("Unable to get response for client request " + msg.getId());
}
}
else
{
LOG_ERROR("No listeners for client " + ISTR(clientKey) + " to distribute request: " + msg.getId());
}
return resp;
}
示例8: SPELLipcMessage
//=============================================================================
// METHOD: SPELLipcMessageMailbox::cancel()
//=============================================================================
void SPELLipcMessageMailbox::cancel( std::string id )
{
SPELLipcMessageQueueMap::iterator mit;
for( mit = m_queueMap.begin(); mit != m_queueMap.end(); mit++)
{
if (mit->first == id)
{
SPELLipcMessage* dummyResponse = new SPELLipcMessage("dummy");
dummyResponse->setType( MSG_TYPE_RESPONSE );
SPELLipcMessageQueue* queue = mit->second;
queue->push(dummyResponse);
break;
}
}
}
示例9: toSend
//=============================================================================
// METHOD: SPELLexecutorIPC::
//=============================================================================
SPELLipcMessage SPELLexecutorIPC::sendRequest( const std::string& executorId, const SPELLipcMessage& msg, unsigned long timeoutMsec )
{
if (m_connected)
{
SPELLipcMessage toSend(msg);
return m_ipc.sendRequest(toSend,timeoutMsec);
}
else
{
SPELLipcMessage resp = SPELLipcHelper::createErrorResponse("IpcErrorResponse", msg);
resp.set( MessageField::FIELD_ERROR, "Cannot send request" );
resp.set( MessageField::FIELD_REASON, "IPC not connected");
resp.set( MessageField::FIELD_FATAL, PythonConstants::True );
return resp;
}
}
示例10: processRequest
SPELLipcMessage* processRequest( SPELLipcMessage* msg )
{
SPELLipcMessage* resp = SPELLipcHelper::createResponse("dummy", msg);
try
{
std::cout << "request received from " << msg->getKey() << ": " << msg->get("NUM") << std::endl;
resp->setId("resp");
resp->setType(MSG_TYPE_RESPONSE);
resp->set("NUM", msg->get("NUM"));
usleep(200000);
}
catch(SPELLcoreException& ex)
{
std::cerr << "PROCESS ERROR: " << ex.what() << std::endl;
}
return resp;
};
示例11: processRequest
//=============================================================================
// METHOD: SPELLlistenerContext::processRequest
//=============================================================================
SPELLipcMessage SPELLlistenerContext::processRequest( const SPELLipcMessage& msg )
{
DEBUG("Got request: " + msg.getId());
// No request from context yet
return VOID_MESSAGE;
}
示例12: processMessage
//=============================================================================
// METHOD: SPELLlistenerContext::processMessage
//=============================================================================
void SPELLlistenerContext::processMessage( const SPELLipcMessage& msg )
{
DEBUG("Got message: " + msg.getId());
if (msg.getId() == ListenerMessages::MSG_CONTEXT_OPEN)
{
this->onNewContext(msg);
}
else if (msg.getId() == ListenerMessages::MSG_CONTEXT_CLOSED)
{
this->onClosedContext(msg);
}
else
{
LOG_ERROR("Unprocessed message: " + msg.getId())
}
}
示例13: attachContext
//=============================================================================
// METHOD: SPELLlistenerContext::attachContext
//=============================================================================
SPELLipcMessage SPELLlistenerContext::attachContext( const SPELLipcMessage& msg )
{
std::string name;
SPELLipcMessage res = SPELLipcHelper::createResponse(ContextMessages::RSP_ATTACH_CTX, msg);
name = msg.get(MessageField::FIELD_CTX_NAME);
this->fillContextInfo(name, res);
return res;
}
示例14: processMessage
//=============================================================================
// METHOD: SPELLclientIPC::
//=============================================================================
void SPELLclientIPC::processMessage( const SPELLipcMessage& msg )
{
// Get the peer key
int clientKey = msg.getKey();
SPELLclientInterestList* list = getClientInterestList(clientKey);
if (list != NULL)
{
list->distributeMessage(msg);
}
}
示例15: processMessage
//=============================================================================
// METHOD: SPELLexecutorIPC::
//=============================================================================
void SPELLexecutorIPC::processMessage( const SPELLipcMessage& msg )
{
TICK_IN;
DEBUG("[EXCIPC] Received message from executor: " + msg.dataStr());
// Certain messages are for monitoring clients only
if ((msg.getId() != MessageId::MSG_ID_PROMPT_START)&&(msg.getId() != MessageId::MSG_ID_PROMPT_END))
{
DEBUG("[EXCIPC] Forward message to controller");
m_controller.processMessageFromExecutor(msg);
}
if (msg.getId() != ExecutorMessages::MSG_NOTIF_EXEC_CLOSE)
{
DEBUG("[EXCIPC] Forward message to monitoring clients");
notifyMessage(msg);
}
DEBUG("[EXCIPC] Message processed");
TICK_OUT;
}