-
Notifications
You must be signed in to change notification settings - Fork 2
/
irc.js
39 lines (32 loc) · 952 Bytes
/
irc.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
var http = require('http');
var fs = require('fs');
var io = require('socket.io');
var express = require('express');
var ircjs = require('irc-js');
var app = express.createServer();
app.configure(function(){
app.use(express.staticProvider(__dirname + '/public'));
});
app.get('/', function(req, res, next){
res.render('./public/index.html');
});
app.listen(process.ENV['app_port'], process.ENV['app_host']);
var socket = io.listen(app, {
flashPolicyServer: false,
transports: ['htmlfile', 'xhr-multipart', 'xhr-polling', 'jsonp-polling']
});
socket.on('connection', function(client) {
/* var my_timer;
var my_client = client;
my_timer = setInterval(function () {
my_client.send(JSON.stringify({ timestamp: (new Date()).getTime() }));
}, 1000);
*/
client.on('message', function(data) {
console.log(data);
});
client.on('disconnect', function() {
clearTimeout(my_timer);
console.log('disconnect');
});
});