예제 #1
0
파일: Client.cpp 프로젝트: czarlos/RISC
	void process_message(TCPConnection * conn) {				
		NetworkMessage * msg = conn->getMessages()->front();
		// std::cout << "Client " << this << " Received Message: " << std::endl;
		msg->print();
		conn->getMessages()->pop_front();	

		this->send(new ClientJoinMessage("lolz", 90));
	}
예제 #2
0
파일: Client.cpp 프로젝트: czarlos/RISC
	void handle_connect(const boost::system::error_code &err, tcp::resolver::iterator endpoint_itr) {
		if (!err) {
			conn->start();
			conn->doOnMessageReceived(boost::bind(&client::process_message, this, _1));
		}
		else if (endpoint_itr != tcp::resolver::iterator()) {
			// the connection failed - try the next one
			tcp::endpoint endpoint = *endpoint_itr;
			conn->getSocket()->async_connect(endpoint,
				boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoint_itr));
		}
		else {
			std::cout << "Error: " << err.message() << "\n";
		}
	}
void TCPServer::handle_accept(TCPConnection::pointer new_connection, const boost::system::error_code& error) {
	if (!error) {
		new_connection->start();
		connections.push_back(new_connection);
		start_accept();
	}
}
예제 #4
0
void TcpServer::handle_accept(TcpConnection::pointer new_connection,
      const boost::system::error_code& error)
{
    if (!error)
    {
       connectionVector.push_back(new_connection);
       new_connection->start( connectionVector);
    }
    start_accept();
}
예제 #5
0
파일: Client.cpp 프로젝트: czarlos/RISC
	void handle_resolve(const boost::system::error_code& err,
		tcp::resolver::iterator endpoint_iterator) {
		if (!err) {
			tcp::endpoint endpoint = *endpoint_iterator;

			conn->getSocket()->async_connect(endpoint,
				boost::bind(&client::handle_connect, this, boost::asio::placeholders::error, ++endpoint_iterator));
		}
		else {
			std::cout << "Error: " << err.message() << "\n";
		}
	}
예제 #6
0
파일: Client.cpp 프로젝트: czarlos/RISC
	void send(NetworkMessage * msg) {
		conn->send(msg);
	}