summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/munia_proto.cc8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/munia_proto.cc b/src/munia_proto.cc
index 480ba39..6f42c28 100644
--- a/src/munia_proto.cc
+++ b/src/munia_proto.cc
@@ -83,6 +83,7 @@ static void dump_handshake_info(struct lws_tokens *lwst)
typedef std::list<message_t> msgqueue_t;
static std::map<struct libwebsocket *, msgqueue_t > msgqueue;
+struct libwebsocket *current_client = NULL;
int callback_lws_task(struct libwebsocket_context * context,
struct libwebsocket *wsi,
@@ -141,6 +142,8 @@ int callback_lws_task(struct libwebsocket_context * context,
std::string msgstr;
msgstr.append((size_t)LWS_SEND_BUFFER_PRE_PADDING, ' ');
+ if(msgqueue[wsi].size() == 0 && wsi == current_client) msgstr += ";";
+
while(msgqueue[wsi].size() > 0) {
message_t msg = msgqueue[wsi].front();
msgqueue[wsi].pop_front();
@@ -149,7 +152,8 @@ int callback_lws_task(struct libwebsocket_context * context,
if(msgstr.size() > LWS_SEND_BUFFER_PRE_PADDING) msgstr += " ";
msgstr += std::string(buf) + " " + msg_tostring(msg);
}
-
+
+
msgstr.append((size_t)LWS_SEND_BUFFER_POST_PADDING, ' ');
int n = libwebsocket_write(wsi, (unsigned char *)
@@ -179,6 +183,8 @@ int callback_lws_task(struct libwebsocket_context * context,
{
printf("LWS_CALLBACK_RECEIVE\n");
+ current_client = wsi;
+
printf("%s\n", (char*)in);
std::string data;
data.append((char*)in, len);