diff options
Diffstat (limited to 'apps/samples/miles')
-rw-r--r-- | apps/samples/miles/miles.js | 31 | ||||
-rw-r--r-- | apps/samples/miles/miles.scxml | 21 |
2 files changed, 39 insertions, 13 deletions
diff --git a/apps/samples/miles/miles.js b/apps/samples/miles/miles.js index f979266..451306b 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" @@ -93,10 +93,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 +191,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 +298,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..2cad7ba 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"> @@ -53,6 +55,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"> @@ -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> |