Last active
August 29, 2015 14:19
-
-
Save 3rd-Eden/2375c9987221bca89097 to your computer and use it in GitHub Desktop.
lfg.js
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 fs = require('fs') | |
, path = require('path') | |
, Primus = require('primus') | |
, EventEmitter = require('events').EventEmitter | |
, Socket = Primus.createSocket({ transformer: 'engine.io' }); | |
var server = require('http').createServer(function (req, res) { | |
res.setHeader('Content-Type', 'text/html'); | |
if ('/' === req.url) { | |
return require('fs').createReadStream(path.join(__dirname, 'index.html')).pipe(res); | |
} | |
res.setHeader('Content-Type', 'text/javascript'); | |
require('fs').createReadStream(path.join(__dirname, 'primus.js')).pipe(res); | |
}).listen(8080); | |
// | |
// We can attach to server, but EventEmitter works fine because our local server | |
// doesn't need any real-time magic. | |
// | |
var primus = new Primus(new EventEmitter(), { | |
transformer: 'engine.io' | |
}); | |
// | |
// Save the compiled server as primus.js | |
// | |
primus.save(path.join(__dirname ,'primus.js')); |
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": "gist", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"engine.io": "1.5.1", | |
"engine.io-client": "1.5.1", | |
"pem": "1.7.2", | |
"primus": "3.0.2" | |
} | |
} |
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
adfafs |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment