Commit cafb1e27 authored by Simon Wüllhorst's avatar Simon Wüllhorst

Fixed finalize procedure within gameserver.

parent 6ca989f3
......@@ -214,6 +214,7 @@ ssize_t packet_sequenzer(client_info* a_client, ssize_t stream_len)
if (msg_len < a_client->server_info->msg_min_size[a_msg->type]) {
printf("Malformed packet, finalize connection.\n");
finalize_client(a_client);
return -1;
}
handle_client_message(a_client, a_msg);
memmove(a_client->message.buf, a_client->message.buf + msg_len, stream_len - msg_len);
......@@ -224,12 +225,15 @@ ssize_t packet_sequenzer(client_info* a_client, ssize_t stream_len)
void handle_client_rec(client_info* a_client)
{
ssize_t n;
ssize_t stream_len;
if ((n = Recv(a_client->client_fd, (void*)(a_client->message.buf + a_client->message.buf_offset), BUFFER_SIZE - a_client->message.buf_offset, 0)) == 0) {
finalize_client(a_client);
return;
}
//printf("Received %zd bytes, buf offset: %zd \n", n, a_client->message.buf_offset);
a_client->message.buf_offset = packet_sequenzer(a_client, n + a_client->message.buf_offset);
if ((stream_len = packet_sequenzer(a_client, n + a_client->message.buf_offset)) < 0)
return;
a_client->message.buf_offset = stream_len;
}
client_info* initialize_client(game_server_info* server_info, int a_client_fd)
{
......
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