[Pkg-javascript-commits] [sockjs-client] 249/434: Having a global `onmessage` function is a bad idea.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:17 UTC 2014


This is an automated email from the git hooks/post-receive script.

tonnerre-guest pushed a commit to branch master
in repository sockjs-client.

commit ae0d45030a83ead79ae36c2cf339a367fb664306
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Fri Dec 2 11:32:29 2011 +0000

    Having a global `onmessage` function is a bad idea.
    
    As all traffic that goes using postMessage trick is also sent to such function. How could I have missed that!
---
 README.md                        | 2 ++
 tests/html/example-cursors.html  | 4 ++--
 tests/html/smoke-reconnect.html  | 6 ------
 tests/html/smoke-throughput.html | 4 ++--
 4 files changed, 6 insertions(+), 10 deletions(-)

diff --git a/README.md b/README.md
index c0be326..e5f0bd8 100644
--- a/README.md
+++ b/README.md
@@ -262,3 +262,5 @@ There are various browser quirks which we don't intend to address:
    it's advisable to use only valid characters. Using invalid
    characters is a bit slower, as SockJS must escape them before
    sending over the wire.
+ * Having a global function called `onmessage` or such is probably a
+   bad idea.
diff --git a/tests/html/example-cursors.html b/tests/html/example-cursors.html
index 21ca706..1991f5a 100644
--- a/tests/html/example-cursors.html
+++ b/tests/html/example-cursors.html
@@ -64,7 +64,7 @@
         sjs = new SockJS(client_opts.url + '/broadcast', protocol, client_opts.sockjs_opts);
         sjs.onopen = onopen
         sjs.onclose = onclose;
-        sjs.onmessage = onmessage;
+        sjs.onmessage = xonmessage;
     });
     $('#disconnect').click(function() {
         $('#disconnect').attr('disabled', true);
@@ -81,7 +81,7 @@
         $('#disconnect').attr('disabled', true);
     };
     var myself = (''+Math.random()).substr(2);
-    var onmessage = function(e) {
+    var xonmessage = function(e) {
         var msg = JSON.parse(e.data);
         if (msg.id === myself) {
             var td = (new Date()).getTime() - msg.t;
diff --git a/tests/html/smoke-reconnect.html b/tests/html/smoke-reconnect.html
index 6632294..e6138d6 100644
--- a/tests/html/smoke-reconnect.html
+++ b/tests/html/smoke-reconnect.html
@@ -64,12 +64,6 @@
             $('#disconnect').attr('disabled', true);
         }
     };
-    function onmessage(e) {
-            var msg = e.data;
-            var td = (new Date()).getTime() - msg.t;
-            i += 1;
-            send();
-    };
 
     $('#connect').click(function() {
         started = true;
diff --git a/tests/html/smoke-throughput.html b/tests/html/smoke-throughput.html
index e017d8e..712bc9d 100644
--- a/tests/html/smoke-throughput.html
+++ b/tests/html/smoke-throughput.html
@@ -66,7 +66,7 @@
         sjs.send({t: (new Date()).getTime(), payload:payload})
     };
     var i = 0;
-    function onmessage(e) {
+    function xonmessage(e) {
             var msg = e.data;
             var td = (new Date()).getTime() - msg.t;
             $('#latency').text(''+i +'  ' + td + ' ms');
@@ -82,7 +82,7 @@
         sjs = new SockJS(client_opts.url + '/echo', protocol, client_opts.sockjs_opts);
         sjs.onopen = onopen
         sjs.onclose = onclose;
-        sjs.onmessage = onmessage;
+        sjs.onmessage = xonmessage;
     });
     $('#disconnect').click(function() {
         $('#disconnect').attr('disabled', true);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git



More information about the Pkg-javascript-commits mailing list