-update enet submodule

-game server accepts port on start
-improve logic of connected game client
parent 26d79ea7
......@@ -23,8 +23,6 @@ bool GameClient::connect(enet_uint32 hostAddress, enet_uint16 port)
return false;
}
connected = false;
if (enet_initialize () != 0)
{
cerr << "GameClient: an error occurred while initializing ENet." << endl;
......@@ -72,6 +70,8 @@ void GameClient::disconnect()
peer = nullptr;
host = nullptr;
connected = false;
}
void GameClient::sendPacket(const std::string& packet)
......
......@@ -19,7 +19,7 @@ GameServer::~GameServer()
}
bool GameServer::start()
bool GameServer::start(enet_uint16 port)
{
if(started)
{
......@@ -34,7 +34,7 @@ bool GameServer::start()
}
address.host = ENET_HOST_ANY;
address.port = GAME_SERVER_PORT;
address.port = port;
host = enet_host_create (&address /* the address to bind the server host to */,
32 /* allow up to 32 clients and/or outgoing connections */,
......
......@@ -25,7 +25,7 @@ public:
GameServer() {}
~GameServer();
bool start();
bool start(enet_uint16 port);
void stop();
enum Event {
......
......@@ -33,6 +33,10 @@ public:
return ip;
}
const enet_uint32 &getHost() const{
return peer == nullptr ? 0 : peer->address.host;
}
void setIP(const std::string &newIp){
ip = newIp;
}
......
Subproject commit f46fee0acc8e243b2b6910b09693f93c3aad775f
Subproject commit 39a72ab1990014eb399cee9d538fd529df99c6a0
......@@ -12,7 +12,7 @@
int main(int argc, const char * argv[]) {
auto server = new GameServer();
bool started = server->start();
bool started = server->start(18843);
if(started)
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment