本文整理汇总了C++中OutputMessage_ptr::getProtocol方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessage_ptr::getProtocol方法的具体用法?C++ OutputMessage_ptr::getProtocol怎么用?C++ OutputMessage_ptr::getProtocol使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessage_ptr
的用法示例。
在下文中一共展示了OutputMessage_ptr::getProtocol方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: send
void OutputMessagePool::send(OutputMessage_ptr msg)
{
OTSYS_THREAD_LOCK(m_outputPoolLock, "");
OutputMessage::OutputMessageState state = msg->getState();
OTSYS_THREAD_UNLOCK(m_outputPoolLock, "");
if(state == OutputMessage::STATE_ALLOCATED_NO_AUTOSEND)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Sending message - SINGLE" << std::endl;
#endif
if(msg->getConnection())
{
if(!msg->getConnection()->send(msg) && msg->getProtocol())
msg->getProtocol()->onSendMessage(msg);
}
#ifdef __DEBUG_NET__
else
std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
#endif
}
#ifdef __DEBUG_NET__
else
std::cout << "Warning: [OutputMessagePool::send] State != STATE_ALLOCATED_NO_AUTOSEND" << std::endl;
#endif
}
示例2: send
bool Connection::send(OutputMessage_ptr msg) {
LOGt("Connection::send()");
boost::recursive_mutex::scoped_lock lock(m_connectionLock);
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError)
{
return false;
}
TRACK_MESSAGE(msg);
if(!m_pendingWrite)
{
if(msg->getProtocol())
msg->getProtocol()->onSendMessage(msg);
internalSend(msg);
}
else if(m_pendingWrite > 100 && server.configManager().getBool(ConfigManager::FORCE_CLOSE_SLOW_CONNECTION))
{
LOGd("Forcing slow connection to disconnect!");
close();
}
else
{
OutputMessagePool::getInstance()->autoSend(msg);
}
return true;
}
示例3: sendAll
void OutputMessagePool::sendAll()
{
OTSYS_THREAD_LOCK_CLASS lockClass(m_outputPoolLock);
OutputMessageList::iterator it;
for(it = m_toAddQueue.begin(); it != m_toAddQueue.end();)
{
//drop messages that are older than 10 seconds
if(OTSYS_TIME() - (*it)->getFrame() > 10000)
{
if((*it)->getProtocol())
(*it)->getProtocol()->onSendMessage(*it);
it = m_toAddQueue.erase(it);
continue;
}
(*it)->setState(OutputMessage::STATE_ALLOCATED);
m_autoSendOutputMessages.push_back(*it);
++it;
}
m_toAddQueue.clear();
for(it = m_autoSendOutputMessages.begin(); it != m_autoSendOutputMessages.end(); )
{
OutputMessage_ptr omsg = (*it);
#ifdef __NO_PLAYER_SENDBUFFER__
//use this define only for debugging
if(true)
#else
//It will send only messages bigger then 1 kb or with a lifetime greater than 10 ms
if(omsg->getMessageLength() > 1024 || (m_frameTime - omsg->getFrame() > 10))
#endif
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Sending message - ALL" << std::endl;
#endif
if(omsg->getConnection())
{
if(!omsg->getConnection()->send(omsg) && omsg->getProtocol())
omsg->getProtocol()->onSendMessage(omsg);
}
#ifdef __DEBUG_NET__
else
std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
#endif
it = m_autoSendOutputMessages.erase(it);
}
else
++it;
}
}
示例4: send
bool Connection::send(OutputMessage_ptr msg)
{
m_connectionLock.lock();
if(m_closeState == CLOSE_STATE_CLOSING || m_writeError)
{
m_connectionLock.unlock();
return false;
}
msg->getProtocol()->onSendMessage(msg);
if(m_pendingWrite == 0)
{
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::send " << msg->getMessageLength() << std::endl;
#endif
internalSend(msg);
}
else
{
#ifdef __DEBUG_NET__
std::clog << "Connection::send Adding to queue " << msg->getMessageLength() << std::endl;
#endif
m_outputQueue.push_back(msg);
}
m_connectionLock.unlock();
return true;
}
示例5: send
void OutputMessagePool::send(OutputMessage_ptr msg)
{
m_outputPoolLock.lock();
OutputMessage::OutputMessageState state = msg->getState();
m_outputPoolLock.unlock();
if(state == OutputMessage::STATE_ALLOCATED_NO_AUTOSEND)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Sending message - SINGLE" << std::endl;
#endif
if(msg->getConnection())
{
if(!msg->getConnection()->send(msg))
{
// Send only fails when connection is closing (or in error state)
// This call will free the message
msg->getProtocol()->onSendMessage(msg);
}
}
else
{
#ifdef __DEBUG_NET__
std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
#endif
}
}
else
{
#ifdef __DEBUG_NET__
std::cout << "Warning: [OutputMessagePool::send] State != STATE_ALLOCATED_NO_AUTOSEND" << std::endl;
#endif
}
}
示例6: sendAll
void OutputMessagePool::sendAll()
{
boost::recursive_mutex::scoped_lock lockClass(m_outputPoolLock);
OutputMessageMessageList::iterator it;
for(it = m_toAddQueue.begin(); it != m_toAddQueue.end();)
{
//drop messages that are older than 10 seconds
if(OTSYS_TIME() - (*it)->getFrame() > 10 * 1000)
{
(*it)->getProtocol()->onSendMessage(*it);
it = m_toAddQueue.erase(it);
continue;
}
(*it)->setState(OutputMessage::STATE_ALLOCATED);
m_autoSendOutputMessages.push_back(*it);
++it;
}
m_toAddQueue.clear();
for(it = m_autoSendOutputMessages.begin(); it != m_autoSendOutputMessages.end();)
{
OutputMessage_ptr omsg = *it;
#ifdef __NO_PLAYER_SENDBUFFER__
//use this define only for debugging
bool v = 1;
#else
//It will send only messages bigger then 1 kb or with a lifetime greater than 10 ms
bool v = omsg->getMessageLength() > 1024 || (m_frameTime - omsg->getFrame() > 10);
#endif
if(v)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Sending message - ALL" << std::endl;
#endif
if(omsg->getConnection())
{
if(!omsg->getConnection()->send(omsg))
{
// Send only fails when connection is closing (or in error state)
// This call will free the message
omsg->getProtocol()->onSendMessage(omsg);
}
}
else
{
#ifdef __DEBUG_NET__
std::cout << "Error: [OutputMessagePool::send] NULL connection." << std::endl;
#endif
}
it = m_autoSendOutputMessages.erase(it);
}
else
++it;
}
}
示例7: send
bool Connection::send(OutputMessage_ptr msg)
{
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::send init" << std::endl;
#endif
m_connectionLock.lock();
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError)
{
m_connectionLock.unlock();
return false;
}
TRACK_MESSAGE(msg);
if(!m_pendingWrite)
{
if(msg->getProtocol())
msg->getProtocol()->onSendMessage(msg);
#ifdef __DEBUG_NET_DETAIL__
std::clog << "Connection::send " << msg->size() << std::endl;
#endif
internalSend(msg);
}
else if(m_pendingWrite > 100 && g_config.getBool(ConfigManager::FORCE_CLOSE_SLOW_CONNECTION))
{
std::clog << "NOTICE: Forcing slow connection to disconnect!" << std::endl;
close();
}
else
{
#ifdef __DEBUG_NET__
std::clog << "Connection::send Adding to queue " << msg->size() << std::endl;
#endif
OutputMessagePool::getInstance()->autoSend(msg);
}
m_connectionLock.unlock();
return true;
}
示例8: send
void OutputMessagePool::send(OutputMessage_ptr msg)
{
m_outputPoolLock.lock();
OutputMessage::OutputMessageState state = msg->getState();
m_outputPoolLock.unlock();
if (state == OutputMessage::STATE_ALLOCATED_NO_AUTOSEND) {
Connection_ptr connection = msg->getConnection();
if (connection && !connection->send(msg)) {
// Send only fails when connection is closing (or in error state)
// This call will free the message
msg->getProtocol()->onSendMessage(msg);
}
}
}
示例9: send
bool Connection::send(OutputMessage_ptr msg)
{
std::lock_guard<std::recursive_mutex> lockClass(m_connectionLock);
if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) {
return false;
}
if (m_pendingWrite == 0) {
msg->getProtocol()->onSendMessage(msg);
internalSend(msg);
} else {
OutputMessagePool::getInstance()->addToAutoSend(msg);
}
return true;
}
示例10: send
bool Connection::send(OutputMessage_ptr msg)
{
m_connectionLock.lock();
if (m_connectionState != CONNECTION_STATE_OPEN || m_writeError) {
m_connectionLock.unlock();
return false;
}
if (m_pendingWrite == 0) {
msg->getProtocol()->onSendMessage(msg);
internalSend(msg);
} else {
OutputMessagePool::getInstance()->addToAutoSend(msg);
}
m_connectionLock.unlock();
return true;
}
示例11: sendAll
void OutputMessagePool::sendAll()
{
std::lock_guard<std::recursive_mutex> lockClass(m_outputPoolLock);
const int64_t dropTime = m_frameTime - 10000;
const int64_t frameTime = m_frameTime - 10;
for (OutputMessage_ptr omsg : m_toAddQueue) {
const int64_t msgFrame = omsg->getFrame();
if (msgFrame >= dropTime) {
omsg->setState(OutputMessage::STATE_ALLOCATED);
if (frameTime > msgFrame) {
m_autoSendOutputMessages.push_front(omsg);
} else {
m_autoSendOutputMessages.push_back(omsg);
}
} else {
//drop messages that are older than 10 seconds
omsg->getProtocol()->onSendMessage(omsg);
}
}
m_toAddQueue.clear();
for (auto it = m_autoSendOutputMessages.begin(), end = m_autoSendOutputMessages.end(); it != end; it = m_autoSendOutputMessages.erase(it)) {
OutputMessage_ptr omsg = *it;
if (frameTime <= omsg->getFrame()) {
break;
}
Connection_ptr connection = omsg->getConnection();
if (connection && !connection->send(omsg)) {
// Send only fails when connection is closing (or in error state)
// This call will free the message
omsg->getProtocol()->onSendMessage(omsg);
}
}
}
示例12: send
bool Connection::send(OutputMessage_ptr msg)
{
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Connection::send init" << std::endl;
#endif
m_connectionLock.lock();
if(m_connectionState != CONNECTION_STATE_OPEN || m_writeError){
m_connectionLock.unlock();
return false;
}
if(m_pendingWrite == 0){
msg->getProtocol()->onSendMessage(msg);
TRACK_MESSAGE(msg);
#ifdef __DEBUG_NET_DETAIL__
std::cout << "Connection::send " << msg->getMessageLength() << std::endl;
#endif
internalSend(msg);
}
else{
#ifdef __DEBUG_NET__
std::cout << "Connection::send Adding to queue " << msg->getMessageLength() << std::endl;
#endif
TRACK_MESSAGE(msg);
OutputMessagePool* outputPool = OutputMessagePool::getInstance();
outputPool->addToAutoSend(msg);
}
m_connectionLock.unlock();
return true;
}