本文整理汇总了C++中sipmessage::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的16个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: writeMessage
void SIPTransaction::writeMessage(SIPMessage::Ptr pMsg, const OSS::IPAddress& remoteAddress)
{
OSS::mutex_lock lock(_mutex);
if (!_transport)
{
OSS_LOG_ERROR("SIPTransaction::writeMessage does not have a transport to use");
return;
}
if (SIPXOR::isEnabled() && _isXOREncrypted)
{
pMsg->setProperty("xor", "1");
}
if (_fsm->onSendMessage(pMsg))
{
std::ostringstream logMsg;
logMsg << _logId << ">>> " << pMsg->startLine()
<< " LEN: " << pMsg->data().size()
<< " SRC: " << _transport->getLocalAddress().toIpPortString()
<< " DST: " << remoteAddress.toIpPortString()
<< " ENC: " << _isXOREncrypted
<< " PROT: " << _transport->getTransportScheme();
OSS::log_information(logMsg.str());
if (OSS::log_get_level() >= OSS::PRIO_DEBUG)
OSS::log_debug(pMsg->createLoggerData());
_transport->writeMessage(pMsg,
remoteAddress.toString(),
OSS::string_from_number<unsigned short>(remoteAddress.getPort()));
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:33,代码来源:SIPTransaction.cpp
示例2: createClientTransaction
SIPTransaction::Ptr SIPFSMDispatch::createClientTransaction(const SIPMessage::Ptr& pRequest)
{
if (!pRequest->isRequest())
throw OSS::SIP::SIPException("Sending a response using sendRequest() method is illegal");
std::string id;
if (!pRequest->getTransactionId(id))
throw OSS::SIP::SIPException("Unable to determine transaction identifier");
SIPTransaction::Ptr trn;
SIPTransportSession::Ptr nullTransport;
bool isAck = false;
if (OSS::string_caseless_starts_with(pRequest->startLine(), "invite"))
{
//
// This is an ICT
//
trn = _ict.findTransaction(pRequest, nullTransport);
}
else
{
//
// This is an NICT
//
isAck = pRequest->isRequest(OSS::SIP::REQ_ACK);
if (!isAck)
{
trn = _nict.findTransaction(pRequest, nullTransport);
}
}
return trn;
}
开发者ID:,项目名称:,代码行数:33,代码来源:
示例3: getBodyType
static SIPB2BHandler::MessageType getBodyType(const SIPMessage::Ptr& pRequest)
{
std::string cseq = pRequest->hdrGet("cseq");
if (cseq.empty())
return SIPB2BHandler::TYPE_INVALID;
OSS::string_to_upper(cseq);
if (OSS::string_ends_with(cseq, "INVITE") ||
OSS::string_ends_with(cseq, "UPDATE") ||
OSS::string_ends_with(cseq, "ACK") ||
OSS::string_ends_with(cseq, "PRACK"))
{
if (pRequest->getBody().empty())
return SIPB2BHandler::TYPE_INVALID;
std::string contentType = pRequest->hdrGet("content-type");
OSS::string_to_lower(contentType);
if (contentType != "application/sdp")
return SIPB2BHandler::TYPE_INVALID;
return SIPB2BHandler::TYPE_SDP;
}
return SIPB2BHandler::TYPE_INVALID;
}
开发者ID:ezuce,项目名称:oss_core,代码行数:25,代码来源:SIPB2BTransactionManager.cpp
示例4: if
SIPMessage::Ptr SIPB2BTransactionManager::onAuthenticateTransaction(
const SIPMessage::Ptr& pRequest, SIPB2BTransaction::Ptr pTransaction)
{
std::string maxForwards = pRequest->hdrGet("max-forwards");
if (maxForwards.empty())
{
maxForwards = "70";
}
int maxF = OSS::string_to_number<int>(maxForwards.c_str());
if (maxF == 0)
{
return pRequest->createResponse(SIPMessage::CODE_483_TooManyHops);
}
--maxF;
pRequest->hdrRemove("max-forwards");
pRequest->hdrSet("Max-Forwards", OSS::string_from_number(maxF).c_str());
SIPB2BHandler::Ptr pHandler = findHandler(pRequest);
if (pHandler)
{
return pHandler->onAuthenticateTransaction(pRequest, pTransaction);
}
else if (_pDefaultHandler)
{
return _pDefaultHandler->onAuthenticateTransaction(pRequest, pTransaction);
}
return pRequest->createResponse(405, "No Corresponding Handler");
}
开发者ID:ezuce,项目名称:oss_core,代码行数:28,代码来源:SIPB2BTransactionManager.cpp
示例5: dispatchMessage
void EndpointListener::dispatchMessage(const SIPMessage::Ptr& pRequest)
{
if (_dispatch)
{
OSS_LOG_DEBUG(pRequest->createContextId(true) << "EndpointListener::dispatchMessage( " << pRequest->startLine() << " )");
pRequest->setProperty(OSS::PropertyMap::PROP_EndpointName, _endpointName);
pRequest->commitData();
_dispatch(pRequest, _pConnection);
}
else
{
OSS_LOG_ERROR(pRequest->createContextId(true) << "EndpointListener::dispatchMessage( NULL )");
}
}
开发者ID:joegen,项目名称:oss_core,代码行数:14,代码来源:EndpointListener.cpp
示例6: findBranch
SIPTransaction::Ptr SIPTransaction::findBranch(const SIPMessage::Ptr& pRequest)
{
//
// Only a parent transaction can have branches
//
if(!isParent())
return SIPTransaction::Ptr();
OSS::mutex_critic_sec_lock lock(_branchesMutex);
SIPTransaction::Ptr foundBranch;
std::string branch = pRequest->getToTag();
if (branch.empty())
return SIPTransaction::Ptr();
Branches::iterator pBranch = _branches.find(branch);
//
// Branch is non-existent. Create a new one and attach a new FSM to it
//
if (pBranch == _branches.end())
{
foundBranch = SIPTransaction::Ptr(new SIPTransaction(shared_from_this()));
_owner->onAttachFSM(foundBranch);
foundBranch->fsm()->setRequest(fsm()->getRequest());
foundBranch->_owner = _owner;
foundBranch->_responseTU = _responseTU;
_branches[branch] = foundBranch;
}
else
{
foundBranch = pBranch->second;
}
return foundBranch;
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:34,代码来源:SIPTransaction.cpp
示例7: writeMessage
void SIPWebSocketConnection::writeMessage(SIPMessage::Ptr msg)
/// Send a SIP message using this session.
{
if (_pServerConnection)
{
_pServerConnection->send(msg->data(), websocketpp::frame::opcode::BINARY);
}
}
开发者ID:ossapp,项目名称:oss_core,代码行数:8,代码来源:SIPWebSocketConnection.cpp
示例8: monitorEvents
void EndpointListener::monitorEvents()
{
OSS_LOG_NOTICE("EndpointListener::monitorEvents( " << _endpointName << " ) - STARTED processing events");
handleStart();
while(!_isTerminating)
{
SIPMessage::Ptr pRequest;
_eventQueue.dequeue(pRequest);
if (pRequest)
{
OSS_LOG_DEBUG(pRequest->createContextId(true) << "EndpointListener::monitorEvents( " << _endpointName << " ) - processing event " << pRequest->startLine());
onHandleEvent(pRequest);
}
else
{
OSS_LOG_DEBUG("EndpointListener::monitorEvents( " << _endpointName << " ) - dropping NULL event");
}
}
handleStop();
OSS_LOG_NOTICE("EndpointListener::monitorEvents( " << _endpointName << " ) TERMINATED");
}
开发者ID:joegen,项目名称:oss_core,代码行数:21,代码来源:EndpointListener.cpp
示例9: sendRequestDirect
void OSSSIP::sendRequestDirect(const SIPMessage::Ptr& pRequest,
const OSS::IPAddress& localAddress,
const OSS::IPAddress& remoteAddress)
{
std::string transport;
if (SIPVia::msgGetTopViaTransport(pRequest.get(), transport))
{
std::string transportId;
pRequest->getProperty("transport-id", transportId);
if (transportId.empty())
transportId="0";
OSS_LOG_DEBUG("Sending request directly protocol=" << transport << " id=" << transportId);
SIPTransportSession::Ptr client = _fsmDispatch.transport().createClientTransport(localAddress, remoteAddress, transport, transportId);
if (client)
client->writeMessage(pRequest, remoteAddress.toString(), OSS::string_from_number(remoteAddress.getPort()));
else
OSS_LOG_ERROR("OSSSIP::sendRequestDirect failed - Unable to create client transport");
}
else
{
OSS_LOG_ERROR("OSSSIP::sendRequestDirect failed - Unable to determine transport protocol.")
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:24,代码来源:OSSSIP.cpp
示例10: _postRouteCallback
SIPMessage::Ptr SIPB2BTransactionManager::onRouteTransaction(
SIPMessage::Ptr& pRequest,
SIPB2BTransaction::Ptr pTransaction,
OSS::IPAddress& localInterface,
OSS::IPAddress& target)
{
SIPB2BHandler::Ptr pHandler = findDomainRouter(pRequest);
if (pHandler)
{
bool handled = false;
SIPMessage::Ptr result = pHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target, handled);
if (handled)
return result;
}
pHandler = findHandler(pRequest);
if (pHandler)
{
SIPMessage::Ptr result = pHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target);
//
// _postRouteCallback is currently set by
// the SBCStaticRouter class that allows static router
// to bypass the results of the javascript layer.
//
if (_postRouteCallback)
return _postRouteCallback(pRequest, result, pTransaction, localInterface, target);
return result;
}
else if (_pDefaultHandler)
{
SIPMessage::Ptr result = _pDefaultHandler->onRouteTransaction(pRequest, pTransaction, localInterface, target);
//
// _postRouteCallback is currently set by
// the SBCStaticRouter class that allows static router
// to bypass the results of the javascript layer.
//
if (_postRouteCallback)
return _postRouteCallback(pRequest, result, pTransaction, localInterface, target);
return result;
}
return pRequest->createResponse(405, "No Corresponding Handler");
}
开发者ID:ezuce,项目名称:oss_core,代码行数:42,代码来源:SIPB2BTransactionManager.cpp
示例11: lock
void SIPTransaction::sendAckFor2xx(
const SIPMessage::Ptr& pAck,
const OSS::IPAddress& dialogTarget)
{
OSS::mutex_lock lock(_mutex);
if (!_dialogTarget.isValid())
_dialogTarget = dialogTarget;
if (SIPXOR::isEnabled() && _isXOREncrypted)
{
pAck->setProperty("xor", "1");
}
if (_transport->isReliableTransport())
{
writeMessage(pAck);
}
else
{
writeMessage(pAck, dialogTarget);
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:22,代码来源:SIPTransaction.cpp
示例12: onSendMessage
bool SIPNict::onSendMessage(SIPMessage::Ptr pMsg)
{
SIPTransaction::Ptr pTransaction = static_cast<SIPTransaction::WeakPtr*>(_owner)->lock();
if (!pTransaction)
return false;
if (pTransaction->getState() == SIPTransaction::TRN_STATE_IDLE)
{
startTimerMaxLifetime(300000); /// five minutes
_pRequest = pMsg;
pTransaction->setState(TRYING);
std::string sTimeout;
if (pMsg->getProperty(OSS::PropertyMap::PROP_TransactionTimeout, sTimeout) && !sTimeout.empty())
{
_timerEValue = OSS::string_to_number<unsigned long>(sTimeout.c_str()) / 64;
}
else
{
_timerEValue = _timerProps.timerE();
}
if (!pTransaction->transport()->isReliableTransport())
{
startTimerE(_timerEValue);
startTimerF(_timerEValue*64);
}
else
{
startTimerF(RELIABLE_TIMER_F_VALUE);
}
return true;
}
return false;
}
开发者ID:,项目名称:,代码行数:36,代码来源:
示例13: onReceivedMessage
void SIPTransaction::onReceivedMessage(SIPMessage::Ptr pMsg, SIPTransportSession::Ptr pTransport)
{
OSS::mutex_lock lock(_mutex);
bool isAck = pMsg->isRequest("ACK");
if (pMsg->isRequest() && !_pInitialRequest && !isAck)
_pInitialRequest = pMsg;
if (_logId.empty())
_logId = pMsg->createContextId(true);
if (!_transport)
_transport = pTransport;
if (!_localAddress.isValid())
_localAddress = pTransport->getLocalAddress();
if (!_remoteAddress.isValid())
_remoteAddress = pTransport->getRemoteAddress();
if (SIPXOR::isEnabled() && !_isXOREncrypted)
{
std::string isXOR;
_isXOREncrypted = pMsg->getProperty("xor", isXOR) && isXOR == "1";
}
if (isParent())
{
std::ostringstream logMsg;
logMsg << _logId << "<<< " << pMsg->startLine()
<< " LEN: " << pTransport->getLastReadCount()
<< " SRC: " << _remoteAddress.toIpPortString()
<< " DST: " << _localAddress.toIpPortString()
<< " EXT: " << "[" << pTransport->getExternalAddress() << "]"
<< " FURI: " << pMsg->hdrGet("from")
<< " ENC: " << _isXOREncrypted
<< " PROT: " << pTransport->getTransportScheme();
OSS::log_information(logMsg.str());
if (OSS::log_get_level() >= OSS::PRIO_DEBUG)
OSS::log_debug(pMsg->createLoggerData());
}
//
// If this is a request and is not an ACK, then the parent IST fsm must always handle it
//
if (isParent() && pMsg->isRequest() && !isAck)
{
_fsm->onReceivedMessage(pMsg, pTransport);
}
else if (!pMsg->isRequest() || isAck)
{
//
// This is a response or an ACK and the transaction could have branched out
//
if (!isParent())
{
_fsm->onReceivedMessage(pMsg, pTransport);
}
else
{
SIPTransaction::Ptr pBranch = findBranch(pMsg);
if (pBranch)
pBranch->onReceivedMessage(pMsg, pTransport);
else
_fsm->onReceivedMessage(pMsg, pTransport);
}
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:70,代码来源:SIPTransaction.cpp
示例14: onReceivedMessage
void SIPNict::onReceivedMessage(SIPMessage::Ptr pMsg, SIPTransportSession::Ptr pTransport)
{
SIPTransaction::Ptr pTransaction = static_cast<SIPTransaction::WeakPtr*>(_owner)->lock();
if (!pTransaction)
return;
int state = pTransaction->getState();
if (!pMsg->isResponse() || state == SIPTransaction::TRN_STATE_TERMINATED || state == COMPLETED)
return;
bool is2xx = pMsg->is2xx();
SIPTransaction::Ptr pParent = pTransaction->getParent();
switch (pTransaction->getState())
{
case SIPTransaction::TRN_STATE_IDLE:
case TRYING:
if (pMsg->is1xx())
{
pTransaction->setState(PROCEEDING);
if (!pTransaction->isParent() && pParent && pParent->getState() < PROCEEDING)
pParent->setState(PROCEEDING);
pTransaction->informTU(pMsg, pTransport);
}
else
{
if (pTransaction->isParent() && !is2xx)
{
//
// If we are the parent or this is and error response
// cancel e and f timers
//
cancelTimerE();
cancelTimerF();
}
else if (!pTransaction->isParent() && is2xx)
{
//
// If this is a branch and it is a 2xx reponse,
// then cancel both parents timers as sell
//
cancelTimerE();
cancelTimerF();
if (pParent)
{
pParent->fsm()->cancelTimerE();
pParent->fsm()->cancelTimerF();
pParent->setState(COMPLETED);
}
}
else if (!pTransaction->isParent() && !is2xx)
{
//
// If this is a branch and it is an error reponse,
// then cancel both parent timers as well if there
// is only one branch
//
cancelTimerE();
cancelTimerF();
if (pParent && pParent->getBranchCount() == 1)
{
pParent->fsm()->cancelTimerE();
pParent->fsm()->cancelTimerF();
pParent->setState(COMPLETED);
}
}
pTransaction->setState(COMPLETED);
pTransaction->informTU(pMsg, pTransport);
if (!pTransport->isReliableTransport())
{
//
// Start the longest time we want to handle retransmissions of 200 OK
//
startTimerK();
}
else
{
pTransaction->setState(SIPTransaction::TRN_STATE_TERMINATED);
if (is2xx || pTransaction->allBranchesCompleted())
{
if (pParent)
pParent->setState(SIPTransaction::TRN_STATE_TERMINATED);
}
}
}
break;
case PROCEEDING:
if (pMsg->is1xx())
{
pTransaction->informTU(pMsg, pTransport);
}
else
{
//.........这里部分代码省略.........
开发者ID:,项目名称:,代码行数:101,代码来源:
示例15: sendRequest
void SIPTransaction::sendRequest(
const SIPMessage::Ptr& pRequest,
const OSS::IPAddress& localAddress,
const OSS::IPAddress& remoteAddress,
SIPTransaction::Callback callback)
{
OSS::mutex_lock lock(_mutex);
if (!pRequest->isRequest())
{
throw OSS::SIP::SIPException("Sending a REQUEST using sendRequest() is illegal!");
}
if (!_pInitialRequest)
{
_pInitialRequest = pRequest;
if (_logId.empty())
_logId = pRequest->createContextId(true);
if (SIPXOR::isEnabled() && !_isXOREncrypted)
{
std::string isXOR;
_isXOREncrypted = pRequest->getProperty("xor", isXOR) && isXOR == "1";
}
}
if (!_responseTU)
_responseTU = callback;
if (_localAddress.getPort() == 0)
_localAddress = localAddress;
if (_remoteAddress.getPort() == 0)
_remoteAddress = remoteAddress;
if (!_transport)
{
if (!_transportService)
throw OSS::SIP::SIPException("Transport Not Ready!");
std::string transport;
if (pRequest->getProperty("target-transport", transport))
{
std::string transportId;
pRequest->getProperty("transport-id", transportId);
_transport = _transportService->createClientTransport(localAddress, remoteAddress, transport, transportId);
}else if (SIPVia::msgGetTopViaTransport(pRequest.get(), transport))
{
_transport = _transportService->createClientTransport(localAddress, remoteAddress, transport);
}
if (!_transport)
throw OSS::SIP::SIPException("Unable to create transport!");
}
if (_transport->isReliableTransport())
{
writeMessage(pRequest);
}
else
{
writeMessage(pRequest, remoteAddress);
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:64,代码来源:SIPTransaction.cpp
示例16: sendResponse
void SIPTransaction::sendResponse(
const SIPMessage::Ptr& pResponse,
const OSS::IPAddress& sendAddress)
{
if (!pResponse->isResponse())
throw OSS::SIP::SIPException("Sending a REQUEST using sendResponse() is illegal!");
SIPTransaction::Ptr pParent = getParent();
if (!_transport && isParent())
throw OSS::SIP::SIPException("Transport Not Ready!");
else if (!isParent() && pParent)
_transport = pParent->_transport;
if (_sendAddress.getPort() == 0)
_sendAddress = sendAddress;
SIPTransaction::Ptr pBranch = findBranch(pResponse);
if (pBranch)
{
pBranch->sendResponse(pResponse, sendAddress);
return;
}
else
{
//
// No branch is found. This instance will handle the response
//
if (_transport && _transport->isReliableTransport())
{
if (_transport->writeKeepAlive())
{
writeMessage(pResponse);
}
else
{
//
// Keep-alive failed so create a new transport
//
if (_localAddress.isValid() && _sendAddress.isValid())
{
//
// According to RFC 3261, if there is any transport failure, we must try to
// re-estabish a connectoin to the via sentby parameter instead
//
std::string transport;
if (SIPVia::msgGetTopViaTransport(pResponse.get(), transport))
{
_transport = _transportService->createClientTransport(_localAddress, _sendAddress, transport);
writeMessage(pResponse);
}
}
else
{
OSS_LOG_ERROR("SIPTransaction::sendResponse - Unable to re-establish transport to send response.");
}
}
}
else if (_transport)
{
//
// This is UDP so a keep-alive check won't do us any good
//
writeMessage(pResponse, _sendAddress);
}
else
{
OSS_LOG_ERROR("SIPTransaction::sendResponse - Transport is NULL.");
}
}
}
开发者ID:arnaudcoquelet,项目名称:oss_core,代码行数:73,代码来源:SIPTransaction.cpp
注:本文中的sipmessage::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论