Last active
December 20, 2015 10:09
-
-
Save 3rd-Eden/6113494 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "socket.io.1.0", | |
"version": "1.0.0", | |
"description": "Socket.IO 1.0 using Primus", | |
"main": "socket.io.1.0.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"repository": { | |
"type": "git", | |
"url": "https://gist.github.com/6113494.git" | |
}, | |
"keywords": [ | |
"socket.io", | |
"primus" | |
], | |
"author": "Arnout Kazemier", | |
"license": "MIT", | |
"bugs": { | |
"url": "https://gist.github.com/6113494" | |
}, | |
"dependencies": { | |
"primus-multiplex": "~0.1.2", | |
"primus-emitter": "~0.1.0", | |
"primus-rooms": "~0.1.6", | |
"primus": "~1.1.2", | |
"engine.io": "~0.6.3" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'use strict'; | |
var Primus = require('primus') | |
, http = require('http'); | |
// | |
// Setup a server that Primus can listen on, pass it in the primus | |
// constructor, select `engine.io` as transformer, add plugins, | |
// ???, profit | |
// | |
var server = http.createServer(); | |
var app = new Primus(server, { transformer: 'engine.io' }); | |
app.use('multiplex', 'primus-multiplex') | |
.use('emitter', 'primus-emitter') | |
.use('rooms', 'primus-rooms'); | |
server.listen(8080); | |
// | |
// Save the client in the root of directory or just use it directly | |
// <script src="http://localhost:8080/primus/primus.js"></script> | |
// | |
app.on('connection', function (socket) { | |
socket.emit('hello', 'world'); | |
socket.join('room'); | |
}); | |
app.channel('foo').on('connection', function (socket) { | |
socket.emit('hello', 'foo'); | |
}); |
Author
3rd-Eden
commented
Sep 18, 2013
socket.emit() doesn't work with Primus Emitter 2.x.
Must be used: socket.send()
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment