diff options
author | Autobuilder at buildslave-ubuntu-12-32 <magnus@alkit.se> | 2013-11-04 14:48:42 (GMT) |
---|---|---|
committer | Autobuilder at buildslave-ubuntu-12-32 <magnus@alkit.se> | 2013-11-04 14:48:42 (GMT) |
commit | 8d466ce1171b78cd234d6e63d09d058888a17e2d (patch) | |
tree | 6f9c876116bbffcfe300bae7547d7654ba91af81 | |
parent | 492bac74e7b4d7e80cfa1fa859a4f7067e3a9910 (diff) | |
download | uscxml-8d466ce1171b78cd234d6e63d09d058888a17e2d.zip uscxml-8d466ce1171b78cd234d6e63d09d058888a17e2d.tar.gz uscxml-8d466ce1171b78cd234d6e63d09d058888a17e2d.tar.bz2 |
added miles/stop
-rw-r--r-- | apps/samples/miles/miles.js | 29 | ||||
-rw-r--r-- | apps/samples/miles/miles.scxml | 15 | ||||
-rw-r--r-- | src/uscxml/plugins/invoker/miles/.MilesSessionInvoker.cpp.swp | bin | 0 -> 16384 bytes | |||
-rw-r--r-- | src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp | 40 |
4 files changed, 69 insertions, 15 deletions
diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js index a340e07..1ef1c68 100644 --- a/apps/samples/miles/miles.js +++ b/apps/samples/miles/miles.js @@ -18,9 +18,11 @@ function Miles(element, params) { // private attributes var scxmlURL = "localhost:8080" var reflectorIp = "88.131.107.12" - var email = "user@smartvortex.eu"; + //var email = "user@smartvortex.eu"; + var email = "mathias"; var problemName = "webconfero"; - var remoteEmail = "other@smartvortex.eu"; + //var remoteEmail = "other@smartvortex.eu"; + var remoteEmail = "stefan"; var participants = []; // empty array var videoCompressions = [ @@ -92,10 +94,25 @@ function Miles(element, params) { } this.disconnect = function() { - self.connected = false; - hideChat(); - self.controlDropDown.dropDown.onCancel(true); - self.controlElem.replaceChild(self.connectDropDown.domNode, self.controlDropDown.domNode); + var query = ""; + query += "?reflector=" + encodeURIComponent(reflectorIp); + query += "&userid=" + encodeURIComponent(email); + query += "&session=" + encodeURIComponent(problemName); + + self.xhr.get({ + // The URL to request + url: "http://" + scxmlURL + "/miles/stop" + query, + // handleAs:"text", + error: function(err) { + console.log(err); + }, + load: function(result) { + self.connected = false; + hideChat(); + self.controlDropDown.dropDown.onCancel(true); + self.controlElem.replaceChild(self.connectDropDown.domNode, self.controlDropDown.domNode); + } + }); } var hideChat = function() { diff --git a/apps/samples/miles/miles.scxml b/apps/samples/miles/miles.scxml index 9e486b4..1889ffa 100644 --- a/apps/samples/miles/miles.scxml +++ b/apps/samples/miles/miles.scxml @@ -11,12 +11,14 @@ <respond status="200" to="_event.data.origin"> <header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload --> <header name="Content-Type" value="text/plain" /> + <header name="Access-Control-Allow-Origin" value="*" /> <content expr="_event.data.image.base64()" /> </respond> <else /> <respond status="200" to="_event.data.origin"> <header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload --> <!-- respond element will add content-type header --> + <header name="Access-Control-Allow-Origin" value="*" /> <content expr="_event.data" /> </respond> </if> @@ -39,7 +41,7 @@ <transition event="http.get" target="idle"> <log label="in" expr="_event.data.path" /> - <script>//dump(_event);</script> + <script>dump(_event);</script> <if cond="false"> <!-- START ############### --> @@ -51,6 +53,15 @@ <param name="session" expr="_event.data.query.session" /> </send> + <!-- STOP ############### --> + <elseif cond="_event.data.pathComponent[1] === 'stop'" /> + <send target="#_miles" event="stop"> + <param name="origin" expr="_event.origin" /> + <param name="reflector" expr="_event.data.query.reflector" /> + <param name="userId" expr="_event.data.query.userid" /> + <param name="session" expr="_event.data.query.session" /> + </send> + <!-- PARTICIPANTS ############### --> <elseif cond="_event.data.pathComponent[1] === 'participants'" /> <send target="#_miles" event="participants"> @@ -153,4 +164,4 @@ </state> </state> -</scxml>
\ No newline at end of file +</scxml> diff --git a/src/uscxml/plugins/invoker/miles/.MilesSessionInvoker.cpp.swp b/src/uscxml/plugins/invoker/miles/.MilesSessionInvoker.cpp.swp Binary files differnew file mode 100644 index 0000000..368f327 --- /dev/null +++ b/src/uscxml/plugins/invoker/miles/.MilesSessionInvoker.cpp.swp diff --git a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp index d4a709b..5887f8a 100644 --- a/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp +++ b/src/uscxml/plugins/invoker/miles/MilesSessionInvoker.cpp @@ -201,9 +201,13 @@ void MilesSessionInvoker::send(const SendRequest& req) { void MilesSessionInvoker::processEventStart(const std::string& origin, const std::string& userid, const std::string& reflector, const std::string& session) { + Event ev; + ev.data.compound["origin"] = origin; //std::cout << req; if(_isRunning) { LOG(ERROR) << "already connected"; + ev.name = "start.error"; + returnEvent(ev); return; } @@ -213,6 +217,8 @@ void MilesSessionInvoker::processEventStart(const std::string& origin, const std rv = miles_connect_reflector_session((char*)reflector.c_str(), (char*)session.c_str()); if (!rv) { LOG(ERROR) << "Could not setup reflector session"; + ev.name = "start.error"; + returnEvent(ev); return; } LOG(ERROR) << "session set up"; @@ -271,24 +277,32 @@ void MilesSessionInvoker::processEventStart(const std::string& origin, const std if(audio_available) _audioThread = new tthread::thread(MilesSessionInvoker::runAudio, this); _videoThread = new tthread::thread(MilesSessionInvoker::runVideo, this); - Event ev; ev.name = "start.reply"; - ev.data.compound["origin"] = origin; returnEvent(ev); } void MilesSessionInvoker::processEventStop(const std::string& origin) { + Event ev; + ev.data.compound["origin"] = origin; + + if(!_isRunning) { + LOG(ERROR) << "not connected"; + ev.name = "stop.error"; + returnEvent(ev); + return; + } int rv = miles_disconnect_reflector_session((char*)_reflector.c_str(), (char*)_session.c_str()); if (!rv) { LOG(ERROR) << "Could not disconnect from reflector session"; + ev.name = "stop.error"; + returnEvent(ev); return; } free_media_buffers(); _isRunning = false; - Event ev; ev.name = "stop.reply"; - ev.data.compound["origin"] = origin; returnEvent(ev); + LOG(ERROR) << "disconnected from reflector session"; } void MilesSessionInvoker::processEventParticipants(const std::string& origin) { @@ -308,6 +322,14 @@ void MilesSessionInvoker::processEventParticipants(const std::string& origin) { } void MilesSessionInvoker::processEventThumbnail(const std::string& origin, const std::string& userid) { + Event ev; + ev.data.compound["origin"] = origin; + if(!_isRunning) { + LOG(ERROR) << "not connected"; + ev.name = "thumbnail.error"; + returnEvent(ev); + return; + } LOG(ERROR) << "processEventThumbnail"; URL imageURL("emptyface.jpg"); imageURL.toAbsolute(_interpreter->getBaseURI()); @@ -315,9 +337,7 @@ void MilesSessionInvoker::processEventThumbnail(const std::string& origin, const ssImage << imageURL; std::string imageContent = ssImage.str(); - Event ev; ev.name = "thumbnail.reply"; - ev.data.compound["origin"] = origin; int has_thumb = 0; struct miles_rtp_in_stream *rtps; @@ -406,9 +426,15 @@ void MilesSessionInvoker::processEventPostText(const std::string& origin, const } void MilesSessionInvoker::processEventGetText(const std::string& origin) { Event ev; - ev.name = "gettext.reply"; ev.data.compound["origin"] = origin; + if(!_isRunning) { + LOG(ERROR) << "not connected"; + ev.name = "gettext.error"; + returnEvent(ev); + return; + } + ev.name = "gettext.reply"; if (rand() % 5 == 0) { // return some mocked up chat message ev.data.compound["message"] = Data(".. and then she was all like: aren't we supposed to discuss work related stuff?", Data::VERBATIM); ev.data.compound["user"] = Data("username1", Data::VERBATIM); |