示例#1
0
文件: server.cpp 项目: oKcerG/SmackTT
void Server::listen()
{
    Connection::pointer connection = Connection::create(*this);
    m_acceptor.async_accept(connection->socket(),
                            boost::bind(&Server::accept, this, connection,
                                        ba::placeholders::error));
}
示例#2
0
文件: server.cpp 项目: oKcerG/SmackTT
void Server::accept(Connection::pointer connection, const boost::system::error_code& error)
{
    std::string ip = connection->socket().remote_endpoint().address().to_v4().to_string();
    std::cout << "-----------------------------------------\n";
    std::cout << "New request coming from " << ip << std::endl;
    if (!error)
        connection->start();
    else
        std::cout << "Server accept error : " << error.message() << std::endl;
    listen();
}
示例#3
0
文件: main.cpp 项目: klupek/asio_http
	void operator()(connection::pointer ptr)
	{
		std::cout << "Request handler" << std::endl;
		std::ostringstream oss;
		oss << ptr->get_request_url() << '\n';
		for (connection::headers_type::const_iterator it = ptr->get_headers().begin(), end = ptr->get_headers().end();
			it != end; ++it)
		{
			oss << "[" << it->first << "]=[" << it->second << "]" << std::endl;
		}
		ptr->send_response(200, oss.str());
	}
	/**
	 * Run when new connection is accepted
	 *
	 * @param new_connection accepted connection
	 * @param error reference to error object
	 */
	void handle_accept(connection::pointer new_connection,
					   const boost::system::error_code& error) 	{
		if (!error) {
			new_connection->start();
			start_accept();
		}
	}
示例#5
0
void server::handle_accept(connection::pointer new_connection, const bs::error_code& error) {
  //	std::cout << "server::handle_accept" << std::endl;
  if (!error) {
    new_connection->start();
    start_accept();
  }
}
示例#6
0
  void handle_accept(connection::pointer new_connection,
      const asio::error_code& error)
  {
    if (!error)
    {
      new_connection->start();
    }

    start_accept();
  }
示例#7
0
int main()
{
  DBus::init();

  Connection::pointer connection = DBus::Connection::create( DBus::BUS_SESSION );

  SignalMessage::pointer message;
  message = SignalMessage::create( "/test/signal/Object",  // object name of the signal
                                   "test.signal.Type",     // interface name of the signal
                                   "Test" );               // name of the signal

  const char* sigvalue1 = "Hello World";

  // append arguments onto signal
  message << sigvalue1;

  // send the message and flush the connection
  connection << message;
  connection->flush();

  usleep(250000);
}
示例#8
0
void NetworkRecorder::handle_accept(Connection::pointer new_connection,
                                    const boost::system::error_code& error)
{
    if (!error)
    {
        {
            OpenCVImage image;
            {
                boost::mutex::scoped_lock lock(m_lock);
                image.copyFrom(m_buffer);
                image.setSize(160, 120);
            }

            new_connection->sendImage(&image);
        }

        start_accept();
    }
}