Skip to content

Instantly share code, notes, and snippets.

@tanepiper
Created May 11, 2012 23:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tanepiper/83b0dfa4ab98cbcadf25 to your computer and use it in GitHub Desktop.
Save tanepiper/83b0dfa4ab98cbcadf25 to your computer and use it in GitHub Desktop.
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