Permalink
Browse files

EasyWebSocket.serverUrl unified in gapp/node version + json2 include …

…in demo for IE8-compatibility
  • Loading branch information...
1 parent 142427f commit bc9c0988a8d7ca4937fc8d348cfc3726c74e83ba @jeromeetienne committed Mar 1, 2011
Showing with 12 additions and 8 deletions.
  1. +2 −1 example/devel-gapp.html
  2. +5 −2 example/devel-node.html
  3. +5 −5 gapp/easyWebSocket-gapp.js
View
@@ -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) }
@@ -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")
View
@@ -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>
@@ -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);
@@ -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")
View
@@ -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"
@@ -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);
@@ -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(){}

0 comments on commit bc9c098

Please sign in to comment.