How to use the now.server function in now

To help you get started, we’ve selected a few now examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github storminwalker / SenchaCon-2011 / examples / extjs-express / server.js View on Github external
me.now = everyone.now,
		me.nowjs = nowjs;
		
	    var parseCookie = require("connect").utils.parseCookie;
 
		nowjs.server.set("authorization", function (data, accept) {
			if (data.headers.cookie) {
				data.cookie = parseCookie(data.headers.cookie);
				data.sessionID = data.cookie[me.sessionConfig.key];
			} else {
			   return accept("No cookie transmitted.", false);
			}
			accept(null, true);
		});
	    
		nowjs.server.sockets.on('connection', function (socket) {
			if(me.connectedUsers.containsKey(socket.handshake.sessionID)) {
				me.connectedUsers.removeAtKey(socket.handshake.sessionID);
			}
			
			me.connectedUsers.add(socket.handshake.sessionID, {
				clientId: socket.id,
				sessionId: socket.handshake.sessionID,
				userId: null
			});
			
			console.log('SessionID ' + socket.handshake.sessionID + ' on ' + 
				socket.id + ' connected!');
		});

		nowjs.on("connect", function() {
			console.log("now connected: " + this.user.clientId);
github storminwalker / SenchaCon-2011 / examples / extjs-express / server.js View on Github external
launchNow: function() {
  		var me = this;
  		me.connectedUsers = Ext.create("Ext.util.MixedCollection");
		
  		var	nowjs = require("now"),
			everyone = nowjs.initialize(me.server);
			
		me.now = everyone.now,
		me.nowjs = nowjs;
		
	    var parseCookie = require("connect").utils.parseCookie;
 
		nowjs.server.set("authorization", function (data, accept) {
			if (data.headers.cookie) {
				data.cookie = parseCookie(data.headers.cookie);
				data.sessionID = data.cookie[me.sessionConfig.key];
			} else {
			   return accept("No cookie transmitted.", false);
			}
			accept(null, true);
		});
	    
		nowjs.server.sockets.on('connection', function (socket) {
			if(me.connectedUsers.containsKey(socket.handshake.sessionID)) {
				me.connectedUsers.removeAtKey(socket.handshake.sessionID);
			}
			
			me.connectedUsers.add(socket.handshake.sessionID, {
				clientId: socket.id,

now

The command-line interface for Vercel

Apache-2.0
Latest version published 4 years ago

Package Health Score

59 / 100
Full package analysis