aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjgeboski <jgeboski@gmail.com>2015-01-27 21:48:34 -0500
committerjgeboski <jgeboski@gmail.com>2015-01-30 16:54:26 -0500
commit94a6b060d56657b830f17b4f9f5d515b69c9effc (patch)
tree7a7726866816bf62e30b278781e39e333a3f9182
parent803b1b68b29cf6b6a0ae01265a69c098f99d1654 (diff)
downloadbitlbee-facebook-94a6b060d56657b830f17b4f9f5d515b69c9effc.tar.gz
bitlbee-facebook-94a6b060d56657b830f17b4f9f5d515b69c9effc.tar.bz2
bitlbee-facebook-94a6b060d56657b830f17b4f9f5d515b69c9effc.tar.xz
Revert "Implemented message sending queue"
This reverts 68c46dd. While the sending queue attempted to ensure each message was sent in order, it also lead to a significant delay in the sending of messages. This is due in part to Facebook taking upwards of a minute or more to reply to a message being sent. Moreover, the queue is not really needed unless messages are being spammed.
-rw-r--r--facebook/facebook-api.c45
-rw-r--r--facebook/facebook-api.h1
2 files changed, 1 insertions, 45 deletions
diff --git a/facebook/facebook-api.c b/facebook/facebook-api.c
index 22233fb..a96175f 100644
--- a/facebook/facebook-api.c
+++ b/facebook/facebook-api.c
@@ -429,38 +429,6 @@ finish:
}
/**
- * Handles message responses which publish the next message queued.
- *
- * @param api The #fb_api.
- * @param pload The message payload.
- **/
-static void fb_api_cb_publish_mr(fb_api_t *api, const GByteArray *pload)
-{
- json_value *json;
- gchar *msg;
- gboolean res;
-
- if (!fb_api_json_new(api, (gchar*) pload->data, pload->len, &json))
- return;
-
- if (!fb_json_bool_chk(json, "succeeded", &res) || !res) {
- fb_api_error(api, FB_API_ERROR, "Failed to send message");
- goto finish;
- }
-
- msg = g_queue_pop_head(api->msgs);
- g_free(msg);
-
- if (!g_queue_is_empty(api->msgs)) {
- msg = g_queue_peek_head(api->msgs);
- fb_api_publish(api, "/send_message2", "%s", msg);
- }
-
-finish:
- json_value_free(json);
-}
-
-/**
* Handles messages which are to be published to the user.
*
* @param api The #fb_api.
@@ -650,11 +618,8 @@ static void fb_api_cb_mqtt_publish(fb_mqtt_t *mqtt, const gchar *topic,
fb_util_hexdump(bytes, 2, "Reading message:");
-
if (g_ascii_strcasecmp(topic, "/orca_typing_notifications") == 0)
fb_api_cb_publish_tn(api, bytes);
- else if (g_ascii_strcasecmp(topic, "/send_message_response") == 0)
- fb_api_cb_publish_mr(api, bytes);
else if (g_ascii_strcasecmp(topic, "/t_ms") == 0)
fb_api_cb_publish_ms(api, bytes);
else if (g_ascii_strcasecmp(topic, "/t_p") == 0)
@@ -694,7 +659,6 @@ fb_api_t *fb_api_new(const fb_api_funcs_t *funcs, gpointer data)
api->data = data;
api->http = fb_http_new(FB_API_AGENT);
api->mqtt = fb_mqtt_new(&muncs, api);
- api->msgs = g_queue_new();
return api;
}
@@ -743,7 +707,6 @@ void fb_api_free(fb_api_t *api)
if (api->err != NULL)
g_error_free(api->err);
- g_queue_free_full(api->msgs, g_free);
fb_mqtt_free(api->mqtt);
fb_http_free(api->http);
@@ -993,7 +956,6 @@ void fb_api_message(fb_api_t *api, fb_id_t id, gboolean thread,
{
guint64 msgid;
const gchar *tpfx;
- gchar *rmsg;
g_return_if_fail(api != NULL);
g_return_if_fail(msg != NULL);
@@ -1001,17 +963,12 @@ void fb_api_message(fb_api_t *api, fb_id_t id, gboolean thread,
msgid = FB_API_MSGID(g_get_real_time() / 1000, g_random_int());
tpfx = thread ? "tfbid_" : "";
- rmsg = g_strdup_printf("{"
+ fb_api_publish(api, "/send_message2", "{"
"\"body\":\"%s\","
"\"to\":\"%s%" FB_ID_FORMAT "\","
"\"sender_fbid\":\"%" FB_ID_FORMAT "\","
"\"msgid\":%" G_GUINT64_FORMAT
"}", msg, tpfx, id, api->uid, msgid);
-
- if (g_queue_is_empty(api->msgs))
- fb_api_publish(api, "/send_message2", "%s", rmsg);
-
- g_queue_push_tail(api->msgs, rmsg);
}
/**
diff --git a/facebook/facebook-api.h b/facebook/facebook-api.h
index 3080125..ef1f66a 100644
--- a/facebook/facebook-api.h
+++ b/facebook/facebook-api.h
@@ -225,7 +225,6 @@ struct fb_api
fb_http_t *http; /** The #fb_http. **/
fb_mqtt_t *mqtt; /** The #fb_mqtt. **/
GError *err; /** The #GError or NULL. **/
- GQueue *msgs; /** The #GQueue of raw messages. **/
fb_id_t uid; /** The The #fb_id of the user. **/
gchar *token; /** The session token. **/