本文整理汇总了C++中connection::Ptr类的典型用法代码示例。如果您正苦于以下问题:C++ Ptr类的具体用法?C++ Ptr怎么用?C++ Ptr使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: setBlocking
void UTPSocket::setBlocking(bool on)
{
blocking = on;
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
ptr->setBlocking(on);
}
示例4:
bt::Uint32 UTPSocket::bytesAvailable() const
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
return ptr->bytesAvailable();
else
return 0;
}
示例5: find
void UTPServer::Private::reset(const utp::Header* hdr)
{
Connection::Ptr c = find(hdr->connection_id);
if (c)
{
c->reset();
}
}
示例6: onSendAppendEntries
int RaftConsensus::onSendAppendEntries(Node& node, msg_appendentries_t& data)
{
Connection::Ptr pConnection = findOrCreateConnection(node);
if (pConnection)
{
return pConnection->onSendAppendEntries(data);
}
return -1;
}
示例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();
}
}
示例8: onSendRequestVote
int RaftConsensus::onSendRequestVote(Node& node, msg_requestvote_t& data)
{
Connection::Ptr pConnection = findOrCreateConnection(node);
if (pConnection)
{
return pConnection->onSendRequestVote(data);
}
return -1;
}
示例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);
}
}
示例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);
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
}
示例15: close
void UTPSocket::close()
{
Connection::Ptr ptr = conn.toStrongRef();
if (ptr)
{
try
{
ptr->close();
}
catch (Connection::TransmissionError)
{
reset();
}
}
}