Esempio n. 1
0
void
ConnectionManager::addConnection(ManagedConnection* connection,
    bool timeout) {
  CHECK_NOTNULL(connection);
  ConnectionManager* oldMgr = connection->getConnectionManager();
  if (oldMgr != this) {
    if (oldMgr) {
      // 'connection' was being previously managed in a different thread.
      // We must remove it from that manager before adding it to this one.
      oldMgr->removeConnection(connection);
    }
    conns_.push_back(*connection);
    connection->setConnectionManager(this);
    if (callback_) {
      callback_->onConnectionAdded(*this);
    }
  }
  if (timeout) {
    scheduleTimeout(connection);
  }
}
Esempio n. 2
0
int callbackRemoveHost(Packet& p)
{
	PacketRemoveHost pp(p);

	//cout << "callbackRemoveHost" << endl;

	ClientData* cd = PolypeerClient::getInstance()->getClientData();
	if(cd!=NULL)
	{
	    ConnectionManager* cm = cd->getConnectionManager();
        //cout <<"getCM"<<endl;
        if(cm!=NULL)
        {
				cm->removeConnection(pp.getIpAddress());
        }



	}

	return 1;
}