network_select_next_server(s);
connect_network(s);
break;
- case NETWORK_CONNECTION_STATE_CONNECTED:
- admin_out(c, "Already connected to `%s'", args[1]);
- break;
case NETWORK_CONNECTION_STATE_LOGIN_SENT:
- case NETWORK_CONNECTION_STATE_MOTD_RECVD:
admin_out(c, "Connect to `%s' already in progress", args[1]);
break;
+ case NETWORK_CONNECTION_STATE_MOTD_RECVD:
+ admin_out(c, "Already connected to `%s'", args[1]);
+ break;
}
}
case NETWORK_CONNECTION_STATE_RECONNECT_PENDING:
admin_out(c, ("%s: Reconnecting"), n->name);
break;
- case NETWORK_CONNECTION_STATE_CONNECTED:
case NETWORK_CONNECTION_STATE_LOGIN_SENT:
case NETWORK_CONNECTION_STATE_MOTD_RECVD:
admin_out(c, ("%s: connected"), n->name);
{
g_assert(s);
- g_assert(s->connection.state == NETWORK_CONNECTION_STATE_CONNECTED);
s->connection.state = NETWORK_CONNECTION_STATE_LOGIN_SENT;
log_network(NULL, LOG_TRACE, s, "Sending login details");
return TRUE;
}
-static gboolean handle_server_connected (GIOChannel *c, GIOCondition cond, void *_server)
-{
- struct network *server = (struct network *)_server;
-
- g_assert(server);
-
- server->connection.state = NETWORK_CONNECTION_STATE_CONNECTED;
- server_send_login(server);
-
- server->connection.incoming_id = g_io_add_watch(server->connection.outgoing, G_IO_IN | G_IO_HUP | G_IO_ERR, handle_server_receive, server);
-
- return FALSE;
-}
-
-
-
static struct tcp_server_config *network_get_next_tcp_server(struct network *n)
{
GList *cur;
s->connection.outgoing = ioc;
- s->connection.incoming_id = g_io_add_watch(s->connection.outgoing, G_IO_OUT, handle_server_connected, s);
+ s->connection.incoming_id = g_io_add_watch(s->connection.outgoing, G_IO_IN | G_IO_HUP | G_IO_ERR, handle_server_receive, s);
+ server_send_login(s);
g_io_channel_unref(s->connection.outgoing);
s->connection.outgoing = g_io_channel_unix_new(sock);
g_io_channel_set_close_on_unref(s->connection.outgoing, TRUE);
- s->connection.state = NETWORK_CONNECTION_STATE_CONNECTED;
server_send_login(s);
enum network_connection_state {
NETWORK_CONNECTION_STATE_NOT_CONNECTED = 0,
NETWORK_CONNECTION_STATE_RECONNECT_PENDING,
- NETWORK_CONNECTION_STATE_CONNECTED,
NETWORK_CONNECTION_STATE_LOGIN_SENT,
NETWORK_CONNECTION_STATE_MOTD_RECVD,
};