[Pkg-javascript-commits] [sockjs-client] 170/434: Update example to use more idiomatic sockjs-node api.

Tonnerre Lombard tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:11 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 93949d91cf767cdf023a2b8b998ca3586a33fb71
Author: Marek Majkowski <majek04 at gmail.com>
Date:   Wed Oct 12 15:49:33 2011 +0100

    Update example to use more idiomatic sockjs-node api.
    
    As for: https://github.com/sockjs/sockjs-node/issues/16
---
 tests/sockjs_app.js | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/tests/sockjs_app.js b/tests/sockjs_app.js
index a6234bf..2ee8c14 100644
--- a/tests/sockjs_app.js
+++ b/tests/sockjs_app.js
@@ -2,31 +2,31 @@ var sockjs = require('sockjs');
 
 exports.install = function(config, server) {
     var sjs_echo = new sockjs.Server(config.opts);
-    sjs_echo.on('open', function(conn){
+    sjs_echo.on('connection', function(conn) {
                     console.log('    [+] echo open    ' + conn);
-                    conn.on('close', function(e) {
+                    conn.on('close', function() {
                                 console.log('    [-] echo close   ' + conn);
                             });
-                    conn.on('message', function(e) {
-                                var d  = JSON.stringify(e.data);
+                    conn.on('message', function(m) {
+                                var d  = JSON.stringify(m);
                                 console.log('    [ ] echo message ' + conn,
                                             d.slice(0,64)+
                                             ((d.length > 64) ? '...' : ''));
-                                conn.send(e.data);
+                                conn.send(m);
                             });
                 });
 
     var sjs_close = new sockjs.Server(config.opts);
-    sjs_close.on('open', function(conn){
+    sjs_close.on('connection', function(conn) {
                      console.log('    [+] clos open    ' + conn);
                      conn.close(3000, "Go away!");
-                     conn.on('close', function(e) {
+                     conn.on('close', function() {
                                  console.log('    [-] clos close   ' + conn);
                              });
                  });
 
     var sjs_ticker = new sockjs.Server(config.opts);
-    sjs_ticker.on('open', function(conn){
+    sjs_ticker.on('connection', function(conn) {
                       console.log('    [+] ticker open   ' + conn);
                       var tref;
                       var schedule = function() {
@@ -34,7 +34,7 @@ exports.install = function(config, server) {
                           tref = setTimeout(schedule, 1000);
                       };
                       tref = setTimeout(schedule, 1000);
-                      conn.on('close', function(e) {
+                      conn.on('close', function() {
                                   clearTimeout(tref);
                                   console.log('    [-] ticker close   ' + conn);
                               });
@@ -42,29 +42,29 @@ exports.install = function(config, server) {
 
     var broadcast = {};
     var sjs_broadcast = new sockjs.Server(config.opts);
-    sjs_broadcast.on('open', function(conn){
+    sjs_broadcast.on('connection', function(conn) {
                          console.log('    [+] broadcast open ' + conn);
                          broadcast[conn.id] = conn;
-                         conn.on('close', function(e) {
+                         conn.on('close', function() {
                                      delete broadcast[conn.id];
                                      console.log('    [-] broadcast close' + conn);
                                  });
-                         conn.on('message', function(e) {
-                                     console.log('    [-] broadcast message', e);
+                         conn.on('message', function(m) {
+                                     console.log('    [-] broadcast message', m);
                                      for(var id in broadcast) {
-                                         broadcast[id].send(e.data);
+                                         broadcast[id].send(m);
                                      }
                                  });
                      });
 
     var sjs_amplify = new sockjs.Server(config.opts);
-    sjs_amplify.on('open', function(conn){
+    sjs_amplify.on('connection', function(conn) {
                     console.log('    [+] amp open    ' + conn);
-                    conn.on('close', function(e) {
+                    conn.on('close', function() {
                                 console.log('    [-] amp close   ' + conn);
                             });
-                    conn.on('message', function(e) {
-                                var n = Math.floor(Number(e.data));
+                    conn.on('message', function(m) {
+                                var n = Math.floor(Number(m));
                                 n = (n > 0 && n < 19) ? n : 1;
                                 console.log('    [ ] amp message: 2^' + n);
                                 conn.send(Array(Math.pow(2, n)+1).join('x'));

-- 
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