示例#1
0
NS_IMETHODIMP nsAbManager::AddAddressBookListener(nsIAbListener *aListener,
                                                  abListenerNotifyFlagValue aNotifyFlags)
{
  NS_ENSURE_ARG_POINTER(aListener);

  abListener newListener(aListener, aNotifyFlags);
  mListeners.AppendElementUnlessExists(newListener);
  return NS_OK;
}
void OlsrEventServer::handleAccept(TcpConnectionPtr connectionPtr,
      const boost::system::error_code& error)
{
  if (!error)
  {
    SER_PRINTF("Got new connection");
    EventListenerPtr newListener(new EventListener(connectionPtr, eventListenerManager_));
    newListener->start();
    dev_send_init();
    tc_send_all_data();
    dev_send();
    // Waiting for new connection again
    waitForConnection();
  }
}
示例#3
0
bool Server::addPort(unsigned portId, Host & host, ProtocolFactory & protocolFactory, std::shared_ptr<ContentManagerFactory> & contentManagerFactory) {
    std::unique_lock<std::mutex> lck(lock);
    // don't add a second port that is the same
    for (auto it = listeners.cbegin(); it != listeners.cend(); ++it) {
        if (*(*it) == portId) {
            return false;
        }
    }
    std::unique_ptr<Listener> newListener(new Listener(portId, host, protocolFactory, contentManagerFactory));
    if (!newListener->inErrorState()) {
        listeners.push_back(std::move(newListener));
        return true;
    }
    return false;
}