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,8 +79,10 @@ wmud_client_close(wmudClient *client, gboolean send_goodbye)
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_socket_close(client->socket, NULL);
g_socket_shutdown(client->socket, TRUE, TRUE, NULL);
clients = g_slist_remove(clients, client);
if (client->player)
if (!client->player->registered)
wmud_player_free(&(client->player));
if (client->buffer)
g_string_free(client->buffer, TRUE);
@ -201,6 +203,7 @@ wmud_client_callback(GSocket *client_socket, GIOCondition condition, wmudClient
{
client->state = WMUD_CLIENT_STATE_PASSWAIT;
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);
}
}

View File

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