From c75bd143e805e8473834087e6cc18eabc8c1e134 Mon Sep 17 00:00:00 2001 From: Kevron Rees Date: Fri, 17 May 2013 14:28:50 -0700 Subject: [PATCH] enable getRanged in websocketsource. causes segfault in the websocket sink end currently --- plugins/websocketsink/protocol | 3 ++- plugins/websocketsourceplugin/websocketsource.cpp | 10 ++++++---- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/plugins/websocketsink/protocol b/plugins/websocketsink/protocol index 5b836a8..ea37448 100644 --- a/plugins/websocketsink/protocol +++ b/plugins/websocketsink/protocol @@ -21,4 +21,5 @@ Subscribe to data: Subscribe to data reply: {"type":"methodReply","name":"subscribe","data":["EngineSpeed"],"transactionid":"d293f670-f0b3-11e1-aff1-0800200c9a66"} - +Get History request: +{"type":"method","name":"getRange","data": {"timeBegin":"1368825008.35948","timeEnd":"1368825018.35948","sequenceBegin":"-1","sequenceEnd":"-1"},"transactionid":"b07589ba-417c-4604-80c6-01c0dcbd524d"} diff --git a/plugins/websocketsourceplugin/websocketsource.cpp b/plugins/websocketsourceplugin/websocketsource.cpp index 0574314..8addf05 100644 --- a/plugins/websocketsourceplugin/websocketsource.cpp +++ b/plugins/websocketsourceplugin/websocketsource.cpp @@ -126,7 +126,7 @@ void WebSocketSource::setConfiguration(map config) } -bool gioPollingFunc(GIOChannel *source,GIOCondition condition,gpointer data) +bool gioPollingFunc(GIOChannel *source, GIOCondition condition, gpointer data) { //This is the polling function. If it return false, glib will stop polling this FD. //printf("Polling...%i\n",condition); @@ -139,14 +139,15 @@ bool gioPollingFunc(GIOChannel *source,GIOCondition condition,gpointer data) pollstruct.events = condition; pollstruct.revents = condition; libwebsocket_service_fd(context,&pollstruct); - if (condition == G_IO_HUP) + if (condition & G_IO_HUP) { //Hang up. Returning false closes out the GIOChannel. //printf("Callback on G_IO_HUP\n"); return false; } - if (condition == G_IO_IN) + if (condition & G_IO_IN) { + } DebugOut() << "gioPollingFunc" << condition; @@ -522,7 +523,7 @@ PropertyList WebSocketSource::supported() int WebSocketSource::supportedOperations() { /// TODO: need to do this correctly based on what the host supports. - return Get | Set; + return Get | Set | GetRanged; } string WebSocketSource::uuid() @@ -586,6 +587,7 @@ void WebSocketSource::getRangePropertyAsync(AsyncRangePropertyReply *reply) uuidRangedReplyMap[uuid] = reply; uuidTimeoutMap[uuid] = amb::currentTime() + 60; ///TODO: 60 second timeout, make this configurable? stringstream s; + s.precision(15); s << "{\"type\":\"method\",\"name\":\"getRange\",\"data\": {"; s << "\"timeBegin\":\"" << reply->timeBegin << "\","; s << "\"timeEnd\":\"" << reply->timeEnd << "\","; -- 2.7.4