Leave channel when disconnecting and remove channel if temporary and last user.
[umurmur.git] / src / client.c
index 58ffb2514294f3656f5567687a9e4b63fdad70f1..68252dc13da5a03360ed9be17f515a2daedc831d 100644 (file)
@@ -220,6 +220,13 @@ void Client_free(client_t *client)
                         ntohs(client->remote_tcp.sin_port));
 
        if (client->authenticated) {
+               int leave_id;
+               leave_id = Chan_playerLeave(client);
+               if (leave_id > 0) { /* Remove temp channel */
+                       sendmsg = Msg_create(ChannelRemove);
+                       sendmsg->payload.channelRemove->channel_id = leave_id;
+                       Client_send_message_except(client, sendmsg);
+               }
                sendmsg = Msg_create(UserRemove);
                sendmsg->payload.userRemove->session = client->sessionId;
                Client_send_message_except(client, sendmsg);
@@ -231,7 +238,6 @@ void Client_free(client_t *client)
        Voicetarget_free_all(client);
        
        list_del(&client->node);
-       list_del(&client->chan_node);
        if (client->ssl)
                SSL_free(client->ssl);
        close(client->tcpfd);