Skip to content

Commit

Permalink
EasyWebSocket.serverUrl unified in gapp/node version + json2 include …
Browse files Browse the repository at this point in the history
…in demo for IE8-compatibility
  • Loading branch information
jeromeetienne committed Mar 1, 2011
1 parent 142427f commit bc9c098
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
3 changes: 2 additions & 1 deletion example/devel-gapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<script>
var basicTest = function(){
// setup EasyWebSocket for local server + loggin
EasyWebSocket.iframeOrigin = "http://localhost:8080";
EasyWebSocket.serverUrl = "http://localhost:8080";
EasyWebSocket.logFunction = function(){ console.log.apply(console, arguments) }


Expand All @@ -21,6 +21,7 @@
}
socket.onmessage= function(event){
console.log("socket onmessage event", event.data, new Date() - sendTime, "ms")
alert("OK")
}
socket.onclose = function(){
console.log("socket onclose")
Expand Down
7 changes: 5 additions & 2 deletions example/devel-node.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<html>
<head>
<!-- json2 is included because some browsers doesnt have it (e.g. ie8) -->
<script src="http://ajax.cdnjs.com/ajax/libs/json2/20110223/json2.js"></script>
<script src="../node/server/node_modules/socket.io/support/socket.io-client/socket.io.js"></script>
<script src="../node/easyWebSocket-node.js"></script>
<!-- <script src="../easyWebSocket-node.min.js"></script>
Expand All @@ -9,8 +11,8 @@
<script>
var basicTest = function(){
// setup EasyWebSocket for local server + loggin
EasyWebSocket.serverUrl = "http://127.0.0.1:8667";
EasyWebSocket.logFunction = function(){ console.log.apply(console, arguments) }
EasyWebSocket.serverUrl = "http://192.168.0.10:8667";
//EasyWebSocket.logFunction = function(){ console.log.apply(console, arguments) }

var url = "ws://example.com/superwa/wa"
var socket = new EasyWebSocket(url);
Expand All @@ -23,6 +25,7 @@
}
socket.onmessage= function(event){
console.log("socket onmessage event", event.data, new Date() - sendTime, "ms")
alert("OK")
}
socket.onclose = function(){
console.log("socket onclose")
Expand Down
10 changes: 5 additions & 5 deletions gapp/easyWebSocket-gapp.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ EasyWebSocket = function(url, protocols)
// define the class logging function
this.log = EasyWebSocket.logFunction;

this.iframeOrigin = EasyWebSocket.iframeOrigin;
this.iframeUrl = this.iframeOrigin + "/gapp/iframe/index.html";
this.serverUrl = EasyWebSocket.serverUrl;
this.iframeUrl = this.serverUrl + "/gapp/iframe/index.html";

// TODO here there is an issue with domReady
// - document.readyState == "complete"
Expand All @@ -54,7 +54,7 @@ EasyWebSocket = function(url, protocols)
// - TODO do i need to chain those handler ?
window.addEventListener("message", function(domEvent){
// if event is not from the iframe, return now
if( domEvent.origin != self.iframeOrigin ) return;
if( domEvent.origin != self.serverUrl ) return;
// notify the local handler
self._onWindowMessage(domEvent)
}, false);
Expand Down Expand Up @@ -205,10 +205,10 @@ EasyWebSocket.CLOSED = 3;
* Configuration
*
* * Devel values
* * EasyWebSocket.iframeOrigin = "http://localhost:8080";
* * EasyWebSocket.serverUrl = "http://localhost:8080";
* * EasyWebSocket.logFunction = console.log.bind(console);
*/
EasyWebSocket.iframeOrigin = "http://easywebsocket.appspot.com";
EasyWebSocket.serverUrl = "http://easywebsocket.appspot.com";
EasyWebSocket.logFunction = function(){}


Expand Down

0 comments on commit bc9c098

Please sign in to comment.