Exemple #1
0
void bithorded::router::ForwardedAsset::addUpstream(const bithorded::Client::Ptr& f, int32_t timeout, const bithorde::RouteTrace requesters) {
	const auto& peername = f->peerName();
	BOOST_ASSERT( _router.connectedFriends().count(peername) );

	auto inserted = _upstream.emplace(std::piecewise_construct, std::make_tuple(peername), std::make_tuple	(shared_from_this(), peername, f, _requestedIds));
	BOOST_ASSERT( inserted.second );

	if ( !f->bind(inserted.first->second, timeout, requesters) )
		_upstream.erase(peername);
}
Exemple #2
0
void Router::onDisconnected(const bithorded::Client::Ptr& client)
{
	string peerName = client->peerName();
	auto iter = _connectedFriends.find(peerName);
	if ((iter != _connectedFriends.end()) && (iter->second == client))
		_connectedFriends.erase(iter);
	if (_friends.count(peerName) && _friends[peerName].port && !_connectors.count(peerName))
		_connectors[peerName] = FriendConnector::create(_server, _friends[peerName]);
}
Exemple #3
0
void Router::onConnected(const bithorded::Client::Ptr& client )
{
	string peerName = client->peerName();
	if (_friends.count(peerName)) {
		LOG4CPLUS_INFO(routerLog, "Friend " << peerName << " connected");
		if (_connectors[peerName].get())
			_connectors[peerName]->cancel();
		_connectors.erase(peerName);
		_connectedFriends[peerName] = client;
	}
}