本文整理汇总了C++中connection::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: connectTo
bool UTPSocket::connectTo(const net::Address& addr)
{
if (!bt::Globals::instance().isUTPEnabled())
return false;
UTPServer & srv = bt::Globals::instance().getUTPServer();
reset();
conn = srv.connectTo(addr);
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr)
return false;
m_state = CONNECTING;
ptr->setBlocking(blocking);
if (blocking)
{
bool ret = ptr->waitUntilConnected();
if (ret)
m_state = CONNECTED;
return ret;
}
return ptr->connectionState() == CS_CONNECTED;
}
开发者ID:KDE,项目名称:libktorrent,代码行数:26,代码来源:utpsocket.cpp
示例2: ready
bool UTPSocket::ready(const net::Poll* p, net::Poll::Mode mode) const
{
Q_UNUSED(p);
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr)
return false;
if (mode == net::Poll::OUTPUT)
{
if (polled_for_writing)
{
polled_for_writing = false;
return ptr->isWriteable();
}
}
else
{
if (polled_for_reading)
{
polled_for_reading = false;
return bytesAvailable() > 0 || ptr->connectionState() == CS_CLOSED;
}
}
return false;
}
开发者ID:KDE,项目名称:libktorrent,代码行数:26,代码来源:utpsocket.cpp
示例3: setBlocking
void UTPSocket::setBlocking(bool on)
{
blocking = on;
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
ptr->setBlocking(on);
}
开发者ID:KDE,项目名称:libktorrent,代码行数:7,代码来源:utpsocket.cpp
示例4:
bt::Uint32 UTPSocket::bytesAvailable() const
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
return ptr->bytesAvailable();
else
return 0;
}
开发者ID:KDE,项目名称:libktorrent,代码行数:8,代码来源:utpsocket.cpp
示例5: find
void UTPServer::Private::reset(const utp::Header* hdr)
{
Connection::Ptr c = find(hdr->connection_id);
if (c)
{
c->reset();
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:8,代码来源:utpserver.cpp
示例6: onSendAppendEntries
int RaftConsensus::onSendAppendEntries(Node& node, msg_appendentries_t& data)
{
Connection::Ptr pConnection = findOrCreateConnection(node);
if (pConnection)
{
return pConnection->onSendAppendEntries(data);
}
return -1;
}
开发者ID:joegen,项目名称:oss_core,代码行数:9,代码来源:RaftConsensus.cpp
示例7: addConnection
void Network::addConnection(Connection::Ptr conn)
{
DEBUG("Adding a file descriptor %d", conn->getFD());
connections[conn->getFD()] = conn;
FD_SET(conn->getFD(), &master_set);
if (max_fd < conn->getFD()) {
max_fd = conn->getFD();
}
}
开发者ID:glew,项目名称:tpserver-cpp,代码行数:9,代码来源:net.cpp
示例8: onSendRequestVote
int RaftConsensus::onSendRequestVote(Node& node, msg_requestvote_t& data)
{
Connection::Ptr pConnection = findOrCreateConnection(node);
if (pConnection)
{
return pConnection->onSendRequestVote(data);
}
return -1;
}
开发者ID:joegen,项目名称:oss_core,代码行数:9,代码来源:RaftConsensus.cpp
示例9: removeConnection
void RaftConsensus::removeConnection(int id)
{
Connection::Ptr pConnection;
pConnection = findConnection(id);
if (!pConnection)
{
pConnection->shutdown();
OSS::mutex_critic_sec_lock lock(_connectionMutex);
_connections.erase(id);
}
}
开发者ID:joegen,项目名称:oss_core,代码行数:11,代码来源:RaftConsensus.cpp
示例10: onReceivedRequestVote
int RaftConsensus::onReceivedRequestVote(const Connection::Ptr& pConnection, msg_requestvote_t& data)
{
OSS::mutex_lock lock(_raftMutex);
int ret = 0;
msg_requestvote_response_t response;
ret = raft_recv_requestvote(_raft, pConnection->getNode().node(), &data, &response);
if (ret != 0)
{
return ret;
}
return pConnection->onSendRequestVoteResponse(response);
}
开发者ID:joegen,项目名称:oss_core,代码行数:12,代码来源:RaftConsensus.cpp
示例11: connectSuccesFull
bool UTPSocket::connectSuccesFull()
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr && ptr->connectionState() == CS_CONNECTED)
{
setRemoteAddress(ptr->remoteAddress());
m_state = CONNECTED;
return true;
}
else
return false;
}
开发者ID:KDE,项目名称:libktorrent,代码行数:12,代码来源:utpsocket.cpp
示例12: onReceivedAppendEntries
int RaftConsensus::onReceivedAppendEntries(const Connection::Ptr& pConnection, msg_appendentries_t& data)
{
OSS::mutex_lock lock(_raftMutex);
int ret = 0;
msg_appendentries_response_t response;
ret = raft_recv_appendentries(_raft, pConnection->getNode().node(), &data, &response);
if (ret != 0)
{
return ret;
}
return pConnection->onSendAppendEntriesResponse(response);
}
开发者ID:joegen,项目名称:oss_core,代码行数:13,代码来源:RaftConsensus.cpp
示例13: if
const net::Address& UTPSocket::getPeerName() const
{
Connection::Ptr ptr = conn.toStrongRef();
if (remote_addr_override)
return addr;
else if (ptr)
return ptr->remoteAddress();
else
{
static net::Address null;
return null;
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:13,代码来源:utpsocket.cpp
示例14: prepare
void UTPSocket::prepare(net::Poll* p, net::Poll::Mode mode)
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr && ptr->connectionState() != CS_CLOSED)
{
UTPServer & srv = bt::Globals::instance().getUTPServer();
srv.preparePolling(p, mode, ptr);
if (mode == net::Poll::OUTPUT)
polled_for_writing = true;
else
polled_for_reading = true;
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:13,代码来源:utpsocket.cpp
示例15: close
void UTPSocket::close()
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
{
try
{
ptr->close();
}
catch (Connection::TransmissionError)
{
reset();
}
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:15,代码来源:utpsocket.cpp
示例16: handleFrame
bool handleFrame(Connection::Ptr pConnection, Frame::Ptr pFrame)
{
if (pFrame->type() == Frame::FRAME_TYPE_EVSU || pFrame->type() == Frame::FRAME_TYPE_EVUN)
{
Poco::RemotingNG::ORB& orb = Poco::RemotingNG::ORB::instance();
std::string suri(pFrame->payloadBegin(), pFrame->getPayloadSize());
Poco::URI dispURI(suri);
dispURI.setAuthority(_pListener->endPoint());
dispURI.setFragment("");
Poco::RemotingNG::EventDispatcher::Ptr pEventDispatcher = orb.findEventDispatcher(dispURI.toString(), Transport::PROTOCOL);
if (pFrame->type() == Frame::FRAME_TYPE_EVSU)
{
Poco::Timestamp expire;
expire += _pListener->getEventSubscriptionTimeout().totalMicroseconds();
pEventDispatcher->subscribe(suri, suri, expire);
}
else
{
pEventDispatcher->unsubscribe(suri);
}
pConnection->returnFrame(pFrame);
return true;
}
return false;
}
开发者ID:JoneXie,项目名称:macchina.io,代码行数:25,代码来源:ServerConnection.cpp
示例17: send
int UTPSocket::send(const bt::Uint8* buf, int len)
{
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr)
return -1;
try
{
return ptr->send(buf, len);
}
catch (Connection::TransmissionError & err)
{
close();
return -1;
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:16,代码来源:utpsocket.cpp
示例18: sendStateToConnection
void Server::sendStateToConnection(Connection::Ptr const& connection)
{
BOOST_FOREACH(Connection::Ptr const& conn, connectionPool_) {
connection->send(Message<MessageType::updateReadiness>(
{conn->id(), conn->ready()}
));
}
开发者ID:jbytheway,项目名称:nibbles,代码行数:7,代码来源:server.cpp
示例19: run
void ServerConnection::run()
{
if (_logger.debug()) _logger.debug("ServerConnection started.");
Connection::Ptr pConnection = new Connection(socket(), Connection::MODE_SERVER);
EventSubscriptionFrameHandler::Ptr pEventSubFrameHandler = new EventSubscriptionFrameHandler(_pListener);
RequestFrameHandler::Ptr pRequestFrameHandler = new RequestFrameHandler(_pListener);
pConnection->pushFrameHandler(pEventSubFrameHandler);
pConnection->pushFrameHandler(pRequestFrameHandler);
_pListener->connectionManager().registerConnection(pConnection);
try
{
_pListener->connectionAccepted(pConnection);
}
catch (Poco::Exception& exc)
{
_logger.error("connectionAccepted event handler threw exception: " + exc.displayText());
}
catch (...)
{
_logger.error("connectionAccepted event handler threw unknown exception");
}
try
{
pConnection->run();
}
catch (Poco::Exception& exc)
{
_logger.log(exc);
}
_pListener->connectionManager().unregisterConnection(pConnection);
pConnection->popFrameHandler(pRequestFrameHandler);
pConnection->popFrameHandler(pEventSubFrameHandler);
if (_logger.debug()) _logger.debug("ServerConnection done.");
}
开发者ID:JoneXie,项目名称:macchina.io,代码行数:34,代码来源:ServerConnection.cpp
示例20: recv
int UTPSocket::recv(bt::Uint8* buf, int max_len)
{
Connection::Ptr ptr = conn.toStrongRef();
if (!ptr || ptr->connectionState() == CS_CLOSED)
return 0;
try
{
if (ptr->bytesAvailable() == 0)
{
if (blocking)
{
if (ptr->waitForData())
return ptr->recv(buf, max_len);
else
return 0; // connection should be closed now
}
else
return -1; // No data ready and not blocking so return -1
}
else
return ptr->recv(buf, max_len);
}
catch (Connection::TransmissionError & err)
{
close();
return -1;
}
}
开发者ID:KDE,项目名称:libktorrent,代码行数:29,代码来源:utpsocket.cpp
注:本文中的connection::Ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论