Example #1
0
void xmpp_close(void)
{
    if (session.wfs < 0)
        return;

    /* Close stream */
    {
        char *s;
        FORMAT(s,
               "<iq to='%s' type='get'>"
               "<query xmlns='urn:cryonline:k01'>"
               "<player_status prev_status='%u' new_status='%u' to='%s'/>"
               "</query>"
               "</iq>",
               session.online.jid.k01,
               session.online.status,
               STATUS_LEFT,
               session.online.channel ? session.online.channel : "");
        stream_send_msg(session.wfs, s);
        free(s);
    }

    stream_send_msg(session.wfs, "</stream:stream>");
    stream_flush(session.wfs);
    close(session.wfs);

    session.wfs = -1;

#ifdef USE_TLS
    tls_close();
    tls_free();
#endif
}
Example #2
0
void *thread_sendstream(void *vargs)
{
    struct thread *t = (struct thread *) vargs;

    thread_register_sigint_handler();

    do {
        char *msg = thread_sendstream_get_next_msg();

        stream_send_msg(session.wfs, msg);
        stream_flush(session.wfs);

        free(msg);
    } while (session.active);

    /* Destroy remaining messages */
    for (unsigned int i = 0; i < SEND_MSG_MAX; ++i)
    {
        free(send_msgs[i]);
        send_msgs[i] = NULL;
    }

    sem_destroy(&_sem_send_msgs_empty);
    sem_destroy(&_sem_send_msgs_full);

    return thread_close(t);
}