Created
February 8, 2014 03:12
-
-
Save Fauntleroy/8876111 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
var shoe = require('shoe'); | |
var through = require('through'); | |
var result = document.getElementById('result'); | |
var stream = shoe('/chat'); | |
stream.on( 'data', function( msg ){ | |
console.log( 'data', msg ); | |
}); | |
say = function( message ){ | |
stream.write( message ); | |
}; |
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
var shoe = require('shoe'); | |
var http = require('http'); | |
var ecstatic = require('ecstatic')(__dirname + '/assets'); | |
var server = http.createServer(ecstatic); | |
server.listen(9999); | |
var Stream = require('stream'); | |
// create a single chat stream all streams talk to | |
var chat_stream = new Stream.Duplex; | |
chat_stream._read = function(){ | |
}; | |
chat_stream._write = function( chunk, encoding, next ){ | |
this.push( chunk ); | |
next(); | |
}; | |
var sock = shoe( function ( stream ){ | |
stream.pipe( chat_stream ); | |
chat_stream.pipe( stream ); | |
}); | |
sock.install( server, '/chat' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment