Changeset 4e4616a for protocols


Ignore:
Timestamp:
2015-11-28T15:59:34Z (4 years ago)
Author:
dequis <dx@…>
Branches:
master
Children:
e61f9d1
Parents:
31d9930
Message:

msn: Buffer writes a bit to send several commands with a single request

Just a 1msec timeout, so that it will run in the next main loop
iteration.

The official clients send the first few commands in the same request,
which reduces roundtrips during login. This commit doesn't do that.

Location:
protocols/msn
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • protocols/msn/gw.c

    r31d9930 r4e4616a  
    2222        gw->ssl = (GATEWAY_PORT == 443);
    2323        gw->poll_timeout = -1;
     24        gw->write_timeout = -1;
    2425        gw->ic = ic;
    2526        gw->md = ic->proto_data;
     
    3435                b_event_remove(gw->poll_timeout);
    3536        }
     37
     38        if (gw->write_timeout != -1) {
     39                b_event_remove(gw->write_timeout);
     40        }
     41
    3642        g_byte_array_free(gw->in, TRUE);
    3743        g_byte_array_free(gw->out, TRUE);
     
    189195}
    190196
    191 void msn_gw_write(struct msn_gw *gw, char *buf, size_t len)
    192 {
    193         g_byte_array_append(gw->out, (const guint8 *) buf, len);
     197static gboolean msn_gw_write_cb(gpointer data, gint source, b_input_condition cond)
     198{
     199        struct msn_gw *gw;
     200       
     201        if (!(gw = msn_gw_from_ic(data))) {
     202                return FALSE;
     203        }
     204
    194205        if (!gw->open) {
    195206                msn_gw_open(gw);
     
    197208                msn_gw_dorequest(gw, NULL);
    198209        }
    199 }
     210
     211        gw->write_timeout = -1;
     212        return FALSE;
     213}
     214
     215void msn_gw_write(struct msn_gw *gw, char *buf, size_t len)
     216{
     217        g_byte_array_append(gw->out, (const guint8 *) buf, len);
     218
     219        /* do a bit of buffering here to send several commands with a single request */
     220        if (gw->write_timeout == -1) {
     221                gw->write_timeout = b_timeout_add(1, msn_gw_write_cb, gw->ic);
     222        }
     223}
  • protocols/msn/msn.h

    r31d9930 r4e4616a  
    112112
    113113        int poll_timeout;
     114        int write_timeout;
    114115
    115116        b_event_handler callback;
Note: See TracChangeset for help on using the changeset viewer.