diff options
Diffstat (limited to 'apps/samples')
-rw-r--r-- | apps/samples/miles/miles.html | 6 | ||||
-rw-r--r-- | apps/samples/miles/miles.js | 32 | ||||
-rw-r--r-- | apps/samples/miles/miles.scxml | 25 |
3 files changed, 45 insertions, 18 deletions
diff --git a/apps/samples/miles/miles.html b/apps/samples/miles/miles.html index 08cfeca..5028621 100644 --- a/apps/samples/miles/miles.html +++ b/apps/samples/miles/miles.html @@ -16,9 +16,9 @@ <script type="text/javascript"> require(["dojo/domReady!"], function(dom) { var milesSession1 = new Miles("miles1"); - var milesSession2 = new Miles("miles2"); - var milesSession3 = new Miles("miles3"); - var milesSession4 = new Miles("miles4"); + var milesSession2 = new Miles("miles2", {"scxmlURL": "localhost:8080", "reflectorIp": "88.131.107.12", "email": "user@smartvortex.eu", "problemName": "webconfero", "remoteEmail": "yetanother@smartvortex.eu"}); + var milesSession3 = new Miles("miles3", {"scxmlURL": "localhost:8080", "reflectorIp": "88.131.107.12", "email": "user@smartvortex.eu", "problemName": "webconfero", "remoteEmail": "stillanother@smartvortex.eu"}); + var milesSession4 = new Miles("miles4", {"scxmlURL": "localhost:8080", "reflectorIp": "88.131.107.12", "email": "user@smartvortex.eu", "problemName": "webconfero", "remoteEmail": "last@smartvortex.eu"}); }); </script> </head> diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js index f979266..d1efb0d 100644 --- a/apps/samples/miles/miles.js +++ b/apps/samples/miles/miles.js @@ -12,8 +12,8 @@ function Miles(element, params) { this.connected = false; this.imageIteration = 0; - this.width = 300; - this.height = 200; + this.width = 320; + this.height = 240; // private attributes var scxmlURL = "localhost:8080" @@ -60,6 +60,7 @@ function Miles(element, params) { if (params && params.reflectorIp) reflectorIp = params.reflectorIp; if (params && params.email) email = params.email; if (params && params.problemName) problemName = params.problemName; + if (params && params.remoteEmail) remoteEmail = params.remoteEmail; // called when dojo loaded all requirements below this.connect = function() { @@ -93,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() { @@ -176,7 +192,7 @@ function Miles(element, params) { }, load: function(result) { if (result.message) { - self.chatOutputElem.innerHTML += stopChatScrolling + " " + Math.random() + ": " + result.message + '<br />'; + self.chatOutputElem.innerHTML += result.message + '<br />'; if (!stopChatScrolling) self.chatOutputElem.scrollTop = self.chatOutputElem.scrollHeight; } @@ -283,7 +299,7 @@ function Miles(element, params) { self.chatSendButton = new Button({ label: "Send", onClick: function(){ - alert(self.chatInput.value); + //alert(self.chatInput.value); self.xhr.post({ // The URL to request url: "http://" + scxmlURL + "/miles/text", diff --git a/apps/samples/miles/miles.scxml b/apps/samples/miles/miles.scxml index 650add8..c1c6c69 100644 --- a/apps/samples/miles/miles.scxml +++ b/apps/samples/miles/miles.scxml @@ -3,7 +3,7 @@ <state id="main"> <invoke type="miles" id="miles"> <finalize> - <log label="out" expr="_event.name" /> + <!-- <log label="out" expr="_event.name" /> --> <script>//dump(_event);</script> <if cond="_event.data.origin"> <!-- <log label="Reply-length" expr="_event.data.base64.length" /> --> @@ -12,6 +12,7 @@ <header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload --> <header name="Access-Control-Allow-Origin" value="*" /> <header name="Content-Type" value="text/plain" /> + <header name="Access-Control-Allow-Origin" value="*" /> <content expr="_event.data.image.base64()" /> </respond> <else /> @@ -19,6 +20,7 @@ <header name="Cache-Control" value="no-cache" /> <!-- force IE to actually reload --> <header name="Access-Control-Allow-Origin" value="*" /> <!-- respond element will add content-type header --> + <header name="Access-Control-Allow-Origin" value="*" /> <content expr="_event.data" /> </respond> </if> @@ -40,7 +42,7 @@ </transition> <transition event="http.get" target="idle"> - <log label="in" expr="_event.data.path" /> + <!-- <log label="in" expr="_event.data.path" /> --> <script>//dump(_event);</script> <if cond="false"> @@ -49,7 +51,16 @@ <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="userid" expr="_event.data.query.userid" /> + <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> @@ -63,7 +74,7 @@ <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" /> + <param name="userid" expr="_event.data.query.userid" /> </send> <!-- VIDEO ON ############### --> @@ -135,8 +146,8 @@ </transition> <transition event="http.post" target="idle"> - <log label="in" expr="_event.data.path" /> - <script>dump(_event);</script> + <!-- <log label="in" expr="_event.data.path" /> --> + <script>//dump(_event);</script> <if cond="false"> <!-- POST TEXT ############### --> @@ -155,4 +166,4 @@ </state> </state> -</scxml>
\ No newline at end of file +</scxml> |