netsync: improve event ctor
parent
9fa0c9f1ba
commit
3ed96fc62a
|
@ -339049,7 +339049,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
case ENET_EVENT_TYPE_CONNECT:;
|
case ENET_EVENT_TYPE_CONNECT:;
|
||||||
/* ensure we have free slot for client */
|
/* ensure we have free slot for client */
|
||||||
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
||||||
msg = va("%d %s", 1, va("%s", "Server is at maximum capacity, disconnecting the peer (::%s:%u)...", ip, event.peer->address.port));
|
msg = va("%d Server is at maximum capacity, disconnecting the peer (::%s:%u)...", 1, ip, event.peer->address.port);
|
||||||
enet_peer_disconnect_now(event.peer, 1);
|
enet_peer_disconnect_now(event.peer, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -339085,7 +339085,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
*(int64_t*)&init_msg[4] = client_id;
|
*(int64_t*)&init_msg[4] = client_id;
|
||||||
server_send_bin(client_id, init_msg, 12);
|
server_send_bin(client_id, init_msg, 12);
|
||||||
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
||||||
msg = va( "%d %s", 0, va("new client rank:%lld from ::%s:%u", client_id, ip, event.peer->address.port ));
|
msg = va( "%d new client rank:%lld from ::%s:%u", 0, client_id, ip, event.peer->address.port );
|
||||||
event.peer->data = (void*)client_id;
|
event.peer->data = (void*)client_id;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -339135,7 +339135,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
|
@ -339143,7 +339143,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, va("%s", ptr));
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from rank:%lld ::%s:%u", sz, (uint64_t)event.peer->data, ip, event.peer->address.port)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from rank:%lld ::%s:%u", -1, sz, (uint64_t)event.peer->data, ip, event.peer->address.port); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
@ -339151,7 +339151,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
msg = va( "%d %s", 0, va("disconnect rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d disconnect rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
/* Reset the peer's client information. */
|
/* Reset the peer's client information. */
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
|
@ -339160,7 +339160,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
||||||
msg = va( "%d %s", 0, va("timeout rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d timeout rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
server_drop_client_peer(event.peer);
|
server_drop_client_peer(event.peer);
|
||||||
|
@ -339233,15 +339233,15 @@ char** client_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
event.type = NETWORK_EVENT_RPC_RESP;
|
event.type = NETWORK_EVENT_RPC_RESP;
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, ptr);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from server", sz)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from server", -1, sz); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
|
|
@ -431,7 +431,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
case ENET_EVENT_TYPE_CONNECT:;
|
case ENET_EVENT_TYPE_CONNECT:;
|
||||||
/* ensure we have free slot for client */
|
/* ensure we have free slot for client */
|
||||||
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
||||||
msg = va("%d %s", 1, va("%s", "Server is at maximum capacity, disconnecting the peer (::%s:%u)...", ip, event.peer->address.port));
|
msg = va("%d Server is at maximum capacity, disconnecting the peer (::%s:%u)...", 1, ip, event.peer->address.port);
|
||||||
enet_peer_disconnect_now(event.peer, 1);
|
enet_peer_disconnect_now(event.peer, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -467,7 +467,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
*(int64_t*)&init_msg[4] = client_id;
|
*(int64_t*)&init_msg[4] = client_id;
|
||||||
server_send_bin(client_id, init_msg, 12);
|
server_send_bin(client_id, init_msg, 12);
|
||||||
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
||||||
msg = va( "%d %s", 0, va("new client rank:%lld from ::%s:%u", client_id, ip, event.peer->address.port ));
|
msg = va( "%d new client rank:%lld from ::%s:%u", 0, client_id, ip, event.peer->address.port );
|
||||||
event.peer->data = (void*)client_id;
|
event.peer->data = (void*)client_id;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -517,7 +517,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
|
@ -525,7 +525,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, va("%s", ptr));
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from rank:%lld ::%s:%u", sz, (uint64_t)event.peer->data, ip, event.peer->address.port)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from rank:%lld ::%s:%u", -1, sz, (uint64_t)event.peer->data, ip, event.peer->address.port); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
@ -533,7 +533,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
msg = va( "%d %s", 0, va("disconnect rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d disconnect rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
/* Reset the peer's client information. */
|
/* Reset the peer's client information. */
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
|
@ -542,7 +542,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
||||||
msg = va( "%d %s", 0, va("timeout rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d timeout rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
server_drop_client_peer(event.peer);
|
server_drop_client_peer(event.peer);
|
||||||
|
@ -615,15 +615,15 @@ char** client_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
event.type = NETWORK_EVENT_RPC_RESP;
|
event.type = NETWORK_EVENT_RPC_RESP;
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, ptr);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from server", sz)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from server", -1, sz); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
|
18
engine/v4k.c
18
engine/v4k.c
|
@ -9957,7 +9957,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
case ENET_EVENT_TYPE_CONNECT:;
|
case ENET_EVENT_TYPE_CONNECT:;
|
||||||
/* ensure we have free slot for client */
|
/* ensure we have free slot for client */
|
||||||
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
if (map_count(clients) >= network_get(NETWORK_CAPACITY)-1) {
|
||||||
msg = va("%d %s", 1, va("%s", "Server is at maximum capacity, disconnecting the peer (::%s:%u)...", ip, event.peer->address.port));
|
msg = va("%d Server is at maximum capacity, disconnecting the peer (::%s:%u)...", 1, ip, event.peer->address.port);
|
||||||
enet_peer_disconnect_now(event.peer, 1);
|
enet_peer_disconnect_now(event.peer, 1);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -9993,7 +9993,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
*(int64_t*)&init_msg[4] = client_id;
|
*(int64_t*)&init_msg[4] = client_id;
|
||||||
server_send_bin(client_id, init_msg, 12);
|
server_send_bin(client_id, init_msg, 12);
|
||||||
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
PRINTF("Client rank %lld for peer ::%s:%u\n", client_id, ip, event.peer->address.port);
|
||||||
msg = va( "%d %s", 0, va("new client rank:%lld from ::%s:%u", client_id, ip, event.peer->address.port ));
|
msg = va( "%d new client rank:%lld from ::%s:%u", 0, client_id, ip, event.peer->address.port );
|
||||||
event.peer->data = (void*)client_id;
|
event.peer->data = (void*)client_id;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -10043,7 +10043,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
|
@ -10051,7 +10051,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, va("%s", ptr));
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from rank:%lld ::%s:%u", sz, (uint64_t)event.peer->data, ip, event.peer->address.port)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from rank:%lld ::%s:%u", -1, sz, (uint64_t)event.peer->data, ip, event.peer->address.port); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
@ -10059,7 +10059,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT:
|
case ENET_EVENT_TYPE_DISCONNECT:
|
||||||
msg = va( "%d %s", 0, va("disconnect rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d disconnect rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
/* Reset the peer's client information. */
|
/* Reset the peer's client information. */
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
|
@ -10068,7 +10068,7 @@ char** server_poll(unsigned timeout_ms) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
case ENET_EVENT_TYPE_DISCONNECT_TIMEOUT:
|
||||||
msg = va( "%d %s", 0, va("timeout rank:%lld", (uint64_t)event.peer->data));
|
msg = va( "%d timeout rank:%lld", 0, (uint64_t)event.peer->data);
|
||||||
FREE(event.peer->data);
|
FREE(event.peer->data);
|
||||||
event.peer->data = NULL;
|
event.peer->data = NULL;
|
||||||
server_drop_client_peer(event.peer);
|
server_drop_client_peer(event.peer);
|
||||||
|
@ -10141,15 +10141,15 @@ char** client_poll(unsigned timeout_ms) {
|
||||||
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
memcpy(&resp_msg[4], resp, strlen(resp)+1);
|
||||||
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
ENetPacket *packet = enet_packet_create(resp_msg, strlen(resp) + 5, ENET_PACKET_FLAG_RELIABLE);
|
||||||
enet_peer_send(event.peer, 0, packet);
|
enet_peer_send(event.peer, 0, packet);
|
||||||
msg = va("%d %s", 0, va("req:%s res:%s", cmdline, resp));
|
msg = va("%d req:%s res:%s", 0, cmdline, resp);
|
||||||
FREE(resp_msg);
|
FREE(resp_msg);
|
||||||
} break;
|
} break;
|
||||||
case MSG_RPC_RESP: {
|
case MSG_RPC_RESP: {
|
||||||
event.type = NETWORK_EVENT_RPC_RESP;
|
event.type = NETWORK_EVENT_RPC_RESP;
|
||||||
msg = va("%d %s", 0, va("%s", ptr));
|
msg = va("%d %s", 0, ptr);
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
msg = va("%d %s", -1, va("unk msg len:%u from server", sz)); /* @TODO: hexdump? */
|
msg = va("%d unk msg len:%u from server", -1, sz); /* @TODO: hexdump? */
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
/* Clean up the packet now that we're done using it. */
|
/* Clean up the packet now that we're done using it. */
|
||||||
|
|
Loading…
Reference in New Issue