[Pkg-javascript-commits] [sockjs-client] 87/434: Forgotten file, due to too wide .gitignore.
Tonnerre Lombard
tonnerre-guest at moszumanska.debian.org
Wed Jan 8 00:47:05 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 1a1ff95fc2608d9d86e0ad80885101338370d677
Author: Marek Majkowski <majek04 at gmail.com>
Date: Thu Aug 18 12:25:08 2011 +0100
Forgotten file, due to too wide .gitignore.
---
.gitignore | 3 ++-
tests/sockjs_app.js | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 67 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index d47d2a4..c52821f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
.pidfile.pid
node_modules
-sockjs*.js
+sockjs.js
+sockjs.min.js
tests/html/lib/*.js
diff --git a/tests/sockjs_app.js b/tests/sockjs_app.js
new file mode 100644
index 0000000..f669fd1
--- /dev/null
+++ b/tests/sockjs_app.js
@@ -0,0 +1,65 @@
+var sockjs = require('sockjs');
+
+exports.install = function(config, server) {
+ var sjs_echo = new sockjs.Server(config.opts);
+ sjs_echo.on('open', function(conn){
+ console.log(' [+] echo open ' + conn);
+ conn.on('close', function(e) {
+ console.log(' [-] echo close ' + conn, e);
+ });
+ conn.on('message', function(e) {
+ var d = JSON.stringify(e.data);
+ console.log(' [ ] echo message ' + conn,
+ d.slice(0,64)+
+ ((d.length > 64) ? '...' : ''));
+ conn.send(e.data);
+ });
+ });
+
+ var sjs_close = new sockjs.Server(config.opts);
+ sjs_close.on('open', function(conn){
+ console.log(' [+] clos open ' + conn);
+ conn.close(3000, "Go away!");
+ conn.on('close', function(e) {
+ console.log(' [-] clos close ' + conn, e);
+ });
+ });
+
+ var sjs_ticker = new sockjs.Server(config.opts);
+ sjs_ticker.on('open', function(conn){
+ console.log(' [+] ticker open ' + conn);
+ var tref;
+ var schedule = function() {
+ conn.send('tick!');
+ tref = setTimeout(schedule, 1000);
+ };
+ tref = setTimeout(schedule, 1000);
+ conn.on('close', function(e) {
+ clearTimeout(tref);
+ console.log(' [-] ticker close ' + conn, e);
+ });
+ });
+
+ var broadcast = {};
+ var sjs_broadcast = new sockjs.Server(config.opts);
+ sjs_broadcast.on('open', function(conn){
+ console.log(' [+] broadcast open ' + conn);
+ broadcast[conn.id] = conn;
+ conn.on('close', function(e) {
+ delete broadcast[conn.id];
+ console.log(' [-] broadcast close' + conn, e);
+ });
+ conn.on('message', function(e) {
+ console.log(' [-] broadcast message', e);
+ for(var id in broadcast) {
+ broadcast[id].send(e.data);
+ }
+ });
+ });
+
+
+ sjs_echo.installHandlers(server, {prefix:'[/]echo'});
+ sjs_close.installHandlers(server, {prefix:'[/]close'});
+ sjs_ticker.installHandlers(server, {prefix:'[/]ticker'});
+ sjs_broadcast.installHandlers(server, {prefix:'[/]broadcast'});
+};
--
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