Fixed connection closing method, and fixed a logout/login problem

Signed-off-by: Gergely POLONKAI <polesz@w00d5t0ck.info>
This commit is contained in:
Gergely POLONKAI 2012-05-17 22:18:04 +02:00
parent e8660f2a31
commit 4e479e0045
2 changed files with 6 additions and 2 deletions

View File

@ -79,9 +79,11 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye)
wmud_client_send(client, "\r\nHave a nice real-world day!\r\n\r\n"); wmud_client_send(client, "\r\nHave a nice real-world day!\r\n\r\n");
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Connection closed."); g_log(G_LOG_DOMAIN, G_LOG_LEVEL_INFO, "Connection closed.");
g_socket_close(client->socket, NULL); g_socket_shutdown(client->socket, TRUE, TRUE, NULL);
clients = g_slist_remove(clients, client); clients = g_slist_remove(clients, client);
wmud_player_free(&(client->player)); if (client->player)
if (!client->player->registered)
wmud_player_free(&(client->player));
if (client->buffer) if (client->buffer)
g_string_free(client->buffer, TRUE); g_string_free(client->buffer, TRUE);
g_source_destroy(client->socket_source); g_source_destroy(client->socket_source);
@ -201,6 +203,7 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient
{ {
client->state = WMUD_CLIENT_STATE_PASSWAIT; client->state = WMUD_CLIENT_STATE_PASSWAIT;
client->player = player; client->player = player;
client->player->registered = TRUE;
wmud_client_send(client, "Please provide us your password: %c%c%c", TELNET_IAC, TELNET_WILL, TELNET_ECHO); wmud_client_send(client, "Please provide us your password: %c%c%c", TELNET_IAC, TELNET_WILL, TELNET_ECHO);
} }
} }

View File

@ -83,6 +83,7 @@ typedef struct _wmudPlayer {
gchar *cpassword; gchar *cpassword;
gchar *email; gchar *email;
gint fail_count; gint fail_count;
gboolean registered;
} wmudPlayer; } wmudPlayer;
typedef struct _wmudClient wmudClient; typedef struct _wmudClient wmudClient;