-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
67 lines (53 loc) · 1.31 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
var fs = require('fs')
, EventEmitter = require('events').EventEmitter
, socketio
, events = new EventEmitter()
, Pusherman;
console.log('hello pusherman')
Pusherman = function Pusherman( server )
{
var Pusherman
, socketio
, _paths;
Pusherman = function Pusherman( server )
{
console.log(arguments);
EventEmitter.call(this);
_paths = {};
console.log(server);
if( typeof server !== "undefined" ) {
//socketio = require('socket.io').listen(server);
} else {
//socketio = require('socket.io').listen(8888);
}
socketio.sockets.on('connection', handleConnection.bind(this));
}
Pusherman.prototype = new EventEmitter();
Pusherman.prototype.addPath = function addPath( path, url )
{
var watcher = fs.watch(path, { persistent : true }, onFileChanges.bind(socketio));
_paths[path] = {
watcher : watcher
, path : path
, url : url
};
}
Pusherman.prototype.removePath = function removePath( path, url )
{
_paths[path].watcher.close();
delete _paths[path];
}
console.log(Pusherman)
return new Pusherman(server);
}
function onFileChanges( event, filename )
{
this.sockets.emit('filechange', {
file : filename
, type : event
});
}
function handleConnection( socket )
{
}
module.exports = exports = Pusherman;