small logging fixes
This commit is contained in:
parent
5171a9f42d
commit
04a55c02a7
@ -44,7 +44,7 @@ void Network::initialize(const std::string &hostname) {
|
|||||||
throw "An error occurred while trying to create an ENet client host.";
|
throw "An error occurred while trying to create an ENet client host.";
|
||||||
}
|
}
|
||||||
|
|
||||||
std::cout << "[Network] connect to " << host << std::endl;
|
std::cout << "[Network] connect to " << hostname << std::endl;
|
||||||
enet_address_set_host(&address, hostname.c_str());
|
enet_address_set_host(&address, hostname.c_str());
|
||||||
address.port = 1234;
|
address.port = 1234;
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ void Network::initialize(const std::string &hostname) {
|
|||||||
/* Wait up to 5 seconds for the connection attempt to succeed. */
|
/* Wait up to 5 seconds for the connection attempt to succeed. */
|
||||||
if (enet_host_service(host, &event, 2000) > 0 && event.type
|
if (enet_host_service(host, &event, 2000) > 0 && event.type
|
||||||
== ENET_EVENT_TYPE_CONNECT) {
|
== ENET_EVENT_TYPE_CONNECT) {
|
||||||
std::cout << "[Network] connected" << host << std::endl;
|
std::cout << "[Network] connected" << std::endl;
|
||||||
} else {
|
} else {
|
||||||
/* Either the 5 seconds are up or a disconnect event was */
|
/* Either the 5 seconds are up or a disconnect event was */
|
||||||
/* received. Reset the peer in the event the 5 seconds */
|
/* received. Reset the peer in the event the 5 seconds */
|
||||||
@ -402,9 +402,11 @@ void Network::service(uint32_t timeout) {
|
|||||||
while (enet_host_service(host, &event, timeout) > 0) {
|
while (enet_host_service(host, &event, timeout) > 0) {
|
||||||
switch (event.type) {
|
switch (event.type) {
|
||||||
case ENET_EVENT_TYPE_CONNECT: {
|
case ENET_EVENT_TYPE_CONNECT: {
|
||||||
std::cout << "A new client connected from "
|
char hostname[256];
|
||||||
<< event.peer->address.host << " "
|
enet_address_get_host(&event.peer->address, hostname,
|
||||||
<< event.peer->address.port << std::endl;
|
sizeof(hostname));
|
||||||
|
std::cout << "[Network] A new client connected from " << hostname
|
||||||
|
<< std::endl;
|
||||||
// bring new client up to date
|
// bring new client up to date
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < GAME_PLAYER_COUNT; i++) {
|
for (i = 0; i < GAME_PLAYER_COUNT; i++) {
|
||||||
|
Loading…
Reference in New Issue
Block a user