Skip to content

Instantly share code, notes, and snippets.

@tanepiper tanepiper/listener.js Secret
Created May 11, 2012

Embed
What would you like to do?
var airport = require('airport');
var fs = require('fs');
var net = require('net');
var air = airport('localhost', 9090);
var listener = air.connect('watcher');
var server = net.createServer(function(socket) {
listener(function(remote) {
console.log(remote);
socket.on('data', function(d) {
console.log(d);
});
this.socket = function(cb) {
cb(socket);
}
});
});
var watch = require('watch');
var airport = require('airport');
var air = airport('localhost', 9090);
var fs = require('fs');
air(function(remote, connection) {
console.log(remote, connection);
watch.createMonitor('./dir1', function(monitor) {
monitor.on('created', function(f, stat) {
remote.socket(function(s) {
fs.createReadStream(f).pipe(s);
});
});
monitor.on('changed', function(f, curr, prev) {
console.log('changed', f, curr, prev);
});
monitor.on('removed', function(f, stat) {
console.log('removed', f, stat);
});
});
this.foo = function() {
}
}).listen('watcher');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.