diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-11-03 16:21:13 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2013-11-03 16:21:13 (GMT) |
commit | cb30bd1f44fcc3a0642a362afd4eaea0d8a7d199 (patch) | |
tree | 8cfcf2ceca801c5d506e03d0e187f440094d1674 /apps/samples/miles/miles.scxml | |
parent | 9caf9ade8ff87a1cb94fb612df4abd96fb5ed239 (diff) | |
download | uscxml-cb30bd1f44fcc3a0642a362afd4eaea0d8a7d199.zip uscxml-cb30bd1f44fcc3a0642a362afd4eaea0d8a7d199.tar.gz uscxml-cb30bd1f44fcc3a0642a362afd4eaea0d8a7d199.tar.bz2 |
First signs of WebSockets and some changes to miles
Diffstat (limited to 'apps/samples/miles/miles.scxml')
-rw-r--r-- | apps/samples/miles/miles.scxml | 155 |
1 files changed, 120 insertions, 35 deletions
diff --git a/apps/samples/miles/miles.scxml b/apps/samples/miles/miles.scxml index 0ecca05..9b1426a 100644 --- a/apps/samples/miles/miles.scxml +++ b/apps/samples/miles/miles.scxml @@ -2,16 +2,25 @@ <script src="http://uscxml.tk.informatik.tu-darmstadt.de/scripts/dump.js" /> <state id="main"> <invoke type="miles" id="miles"> - <param name="foo" expr="'asdf'" /> <finalize> + <script>//dump(_event);</script> <if cond="_event.data.origin"> <!-- <log label="Reply-length" expr="_event.data.base64.length" /> --> - <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.base64" /> - </respond> + <if cond="_event.name === 'thumbnail.reply'"> + <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" /> + <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 --> + <content expr="_event.data" /> + </respond> + </if> + <else /> + <log label="Error" expr="'Event returned from invoker did not specify its origin for a reply'" /> </if> </finalize> </invoke> @@ -19,49 +28,125 @@ <state id="idle"> <!-- XHR CORS preflight respond --> <transition event="http.options" target="idle"> - <script>//dump(_event);</script> <respond status="200" to="_event.origin"> - <header name="Access-Control-Allow-Origin" value="*" /> - <header name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" /> - <header name="Access-Control-Allow-Headers" value="X-Requested-With, Content-Type" /> + <header name="Access-Control-Allow-Origin" value="*" /> <!-- request origins we allow --> + <header name="Access-Control-Allow-Methods" value="POST, GET, OPTIONS" /> <!-- http methods we allow --> + <header name="Access-Control-Allow-Headers" + value="X-Requested-With, X-Content-Encoding, Content-Type" /> <!-- headers we allow --> </respond> </transition> - <transition event="http.*" target="idle"> + <transition event="http.get" target="idle"> <script>//dump(_event);</script> - <if cond="_event.data.pathComponent[1] === 'session'"> - <respond status="200" to="_event.origin" /> - - <elseif cond="_event.data.pathComponent[1] === 'connect'" /> - <script>dump(_event);</script> - <send target="#_miles" event="connect"> - <param name="reflectorIp" expr="_event.data.content.reflectorIp" /> - <param name="email" expr="_event.data.content.email" /> - <param name="problemName" expr="_event.data.content.problemName" /> + <if cond="false"> + + <!-- START ############### --> + <elseif cond="_event.data.pathComponent[1] === 'start'" /> + <send target="#_miles" event="start"> + <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> - <respond status="200" to="_event.origin"> - <header name="Connection" value="close" /> - <header name="Content-Type" value="application/json" /> - <header name="Access-Control-Allow-Origin" value="*" /> - </respond> - - <elseif cond="_event.data.pathComponent[1] === 'disconnect'" /> - <send target="#_miles" event="disconnect"> - <param name="reflectorIp" expr="_event.data.content.reflectorIp" /> - <param name="problemName" expr="_event.data.content.problemName" /> + + <!-- PARTICIPANTS ############### --> + <elseif cond="_event.data.pathComponent[1] === 'participants'" /> + <send target="#_miles" event="participants"> + <param name="origin" expr="_event.origin" /> + </send> + + <!-- THUMBNAIL ############### --> + <elseif cond="_event.data.pathComponent[1] === 'thumbnail'" /> + <send target="#_miles" event="thumbnail"> + <param name="origin" expr="_event.origin" /> + <param name="userId" expr="_event.data.query.userid" /> + </send> + + <!-- VIDEO ON ############### --> + <elseif cond="_event.data.pathComponent[1] === 'videoon'" /> + <send target="#_miles" event="videoon"> + <param name="origin" expr="_event.origin" /> + <param name="userid" expr="_event.data.query.userid" /> + </send> + + <!-- VIDEO OFF ############### --> + <elseif cond="_event.data.pathComponent[1] === 'videooff'" /> + <send target="#_miles" event="videooff"> + <param name="origin" expr="_event.origin" /> + <param name="userid" expr="_event.data.query.userid" /> + </send> + + <!-- AUDIO ON ############### --> + <elseif cond="_event.data.pathComponent[1] === 'audioon'" /> + <send target="#_miles" event="audioon"> + <param name="origin" expr="_event.origin" /> + <param name="userid" expr="_event.data.query.userid" /> + </send> + + <!-- AUDIO OFF ############### --> + <elseif cond="_event.data.pathComponent[1] === 'videooff'" /> + <send target="#_miles" event="audiooff"> + <param name="origin" expr="_event.origin" /> + <param name="userid" expr="_event.data.query.userid" /> </send> - <respond status="200" to="_event.origin" /> - <elseif cond="_event.data.pathComponent[1] === 'image'" /> - <send target="#_miles" event="image"> + <!-- SEND VIDEO ############### --> + <elseif cond="_event.data.pathComponent[1] === 'sendvideo'" /> + <send target="#_miles" event="sendvideo"> <param name="origin" expr="_event.origin" /> + <param name="width" expr="_event.data.query.width" /> + <param name="height" expr="_event.data.query.height" /> + <param name="framerate" expr="_event.data.query.framerate" /> + <param name="compression" expr="_event.data.query.compression" /> + </send> + + <!-- SEND VIDEO OFF ############### --> + <elseif cond="_event.data.pathComponent[1] === 'sendvideooff'" /> + <send target="#_miles" event="sendvideooff"> + <param name="origin" expr="_event.origin" /> + </send> + + <!-- SEND AUDIO ############### --> + <elseif cond="_event.data.pathComponent[1] === 'sendaudio'" /> + <send target="#_miles" event="sendaudio"> + <param name="origin" expr="_event.origin" /> + <param name="encoding" expr="_event.data.query.encoding" /> + </send> + + <!-- SEND AUDIO OFF ############### --> + <elseif cond="_event.data.pathComponent[1] === 'sendaudiooff'" /> + <send target="#_miles" event="sendaudiooff"> + </send> + + <!-- GET TEXT ############### --> + <elseif cond="_event.data.pathComponent[1] === 'gettext'" /> + <send target="#_miles" event="gettext"> + <param name="origin" expr="_event.origin" /> + </send> + + <else /> + <respond status="404" to="_event.origin" /> + </if> + </transition> + + <transition event="http.post" target="idle"> + <script>//dump(_event);</script> + <if cond="false"> + + <!-- POST TEXT ############### --> + <elseif cond="_event.data.pathComponent[1] === 'text'" /> + <send target="#_miles" event="posttext"> + <param name="origin" expr="_event.origin" /> + <param name="userid" expr="_event.data.query.userid" /> + <param name="message" expr="_event.data.content" /> </send> <else /> <respond status="404" to="_event.origin" /> - </if> + </transition> + </state> </state> </scxml>
\ No newline at end of file |