Added an event to search for servers.

Client now broadcasts a serverlistrequest.
An active server will then answer the request and send info about the server.
The client saves this data to a list and presents it to the user.
This commit is contained in:
stiffly
2016-02-19 15:38:09 +01:00
parent 46987beefb
commit 993d804cef
12 changed files with 178 additions and 51 deletions
+7 -1
View File
@@ -4,6 +4,8 @@ using namespace boost::asio::ip;
TCPServer::TCPServer()
{
acceptor = std::unique_ptr<tcp::acceptor>(new tcp::acceptor(m_IOService, tcp::endpoint(tcp::v4(), 27666)));
m_Port = GetPort();
m_Address = GetAddress();
}
TCPServer::~TCPServer()
@@ -76,8 +78,12 @@ void TCPServer::Disconnect()
{
}
int TCPServer::GetPort()
{
return acceptor->local_endpoint().port();
}
std::string TCPServer::Address()
std::string TCPServer::GetAddress()
{
boost::asio::ip::tcp::resolver resolver(m_IOService);
boost::asio::ip::tcp::resolver::query query(boost::asio::ip::tcp::v4(), boost::asio::ip::host_name(), "");