diff options
author | dequis <dx@dxzone.com.ar> | 2015-03-19 13:02:31 -0300 |
---|---|---|
committer | dequis <dx@dxzone.com.ar> | 2015-04-10 14:10:41 -0300 |
commit | e59eec03bee8bb7df76f1a323f0f404754dff8ca (patch) | |
tree | 88bf4a473c68d2b7d9608d1ddb214884a5a32daf | |
parent | cd5fdcf1b6b3ee4e5072e6332b6b8ef83dd5b2b3 (diff) |
msn: switch to long polling http
-rw-r--r-- | protocols/msn/gw.c | 10 | ||||
-rw-r--r-- | protocols/msn/msn.h | 1 |
2 files changed, 9 insertions, 2 deletions
diff --git a/protocols/msn/gw.c b/protocols/msn/gw.c index e046f0c8..eecbdb3b 100644 --- a/protocols/msn/gw.c +++ b/protocols/msn/gw.c @@ -69,6 +69,7 @@ void msn_gw_callback(struct http_request *req) struct msn_gw *gw = req->data; gw->waiting = FALSE; + gw->polling = FALSE; if (!gw->open) { /* the user tried to logout while the request was pending @@ -109,7 +110,7 @@ void msn_gw_callback(struct http_request *req) if (gw->poll_timeout != -1) { b_event_remove(gw->poll_timeout); } - gw->poll_timeout = b_timeout_add(5000, msn_gw_poll_timeout, gw); + gw->poll_timeout = b_timeout_add(500, msn_gw_poll_timeout, gw); } @@ -126,6 +127,11 @@ void msn_gw_dorequest(struct msn_gw *gw, char *args) gw->out = g_byte_array_new(); } + if (!bodylen && !args) { + args = "Action=poll&Lifespan=60"; + gw->polling = TRUE; + } + request = g_strdup_printf(REQUEST_TEMPLATE, gw->session_id ? : "", args ? : "", gw->last_host, bodylen, body ? : ""); @@ -171,7 +177,7 @@ void msn_gw_write(struct msn_gw *gw, char *buf, size_t len) g_byte_array_append(gw->out, (const guint8 *) buf, len); if (!gw->open) { msn_gw_open(gw); - } else if (!gw->waiting) { + } else if (gw->polling || !gw->waiting) { msn_gw_dorequest(gw, NULL); } } diff --git a/protocols/msn/msn.h b/protocols/msn/msn.h index cdc459f5..ba7e4247 100644 --- a/protocols/msn/msn.h +++ b/protocols/msn/msn.h @@ -140,6 +140,7 @@ struct msn_gw { gboolean open; gboolean waiting; + gboolean polling; }; struct msn_data { |