From 71f15b9dd59ee21983c00b9e74c2a1e100e02fb8 Mon Sep 17 00:00:00 2001 From: Jonas Suhr Christensen Date: Fri, 4 May 2012 14:06:29 +0200 Subject: Setting correct observe id on messages. --- src/munia_proto.cc | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/munia_proto.cc b/src/munia_proto.cc index 36c6e5c..d9b068f 100644 --- a/src/munia_proto.cc +++ b/src/munia_proto.cc @@ -203,23 +203,27 @@ int callback_lws_task(struct libwebsocket_context * context, TaskIdList::iterator id = ids.begin(); while(id != ids.end()) { task_t task = task_manager.task(*id); - + message_t createmsg = create_msg_create(task); + createmsg.tid = omi->observe.id; message_t updatemsg = create_msg_update(task); + updatemsg.tid = omi->observe.id; + msgqueue[wsi].push(createmsg); msgqueue[wsi].push(updatemsg); - + id++; } } else if(omi->cmd == cmd::unobserve) { TaskIdList ids = task_manager.subTasks(omi->observe.id); - TaskIdList::iterator id = ids.begin(); - while(id != ids.end()) { + TaskIdList::reverse_iterator id = ids.rbegin(); + while(id != ids.rend()) { task_t task = task_manager.task(*id); message_t removemsg = create_msg_remove(task); + removemsg.tid = omi->observe.id; msgqueue[wsi].push(removemsg); id++; @@ -236,6 +240,8 @@ int callback_lws_task(struct libwebsocket_context * context, clientid_t clientid = (*ci).first; taskid_t tid = (*ci).second; + printf("Observer id of task: %d\n", tid); + message_t msg = *omi; msg.tid = tid; -- cgit v1.2.3