aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErnesto Bazzano <bazza@riseup.net>2012-07-24 23:20:09 -0300
committerErnesto Bazzano <bazza@riseup.net>2012-07-24 23:20:09 -0300
commit20eae78bbe33e18de9c38b242f642ac11708cdab (patch)
tree45622826454402b8efff31fe33910e21ecc17888
parent23338bc463594e8413336c913ab3a8008b92cd36 (diff)
downloadreevo-webirc-20eae78bbe33e18de9c38b242f642ac11708cdab.tar.gz
reevo-webirc-20eae78bbe33e18de9c38b242f642ac11708cdab.zip
Saque archivos de más
-rw-r--r--.gitignore2
-rw-r--r--README.md2
-rw-r--r--[-rwxr-xr-x]server.js13
-rw-r--r--web-irc.js78
4 files changed, 8 insertions, 87 deletions
diff --git a/.gitignore b/.gitignore
index 3c3629e..4ae7a35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,3 @@
1node_modules 1node_modules
2web-irc.sh
3web-irc.js
diff --git a/README.md b/README.md
index ebe0ba0..ce5bba5 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@ Web-IRC
4Notas de mi versión 4Notas de mi versión
5------------------- 5-------------------
6 6
7Mis cambios están hechos bajo Licencia AGPL 7Mis cambios están hechos bajo Licencia `AGPL`
8 8
9###Cambios 9###Cambios
10 10
diff --git a/server.js b/server.js
index d3e6d17..824e581 100755..100644
--- a/server.js
+++ b/server.js
@@ -14,7 +14,6 @@ app.configure('development', function() {
14 app.listen(8337); 14 app.listen(8337);
15}); 15});
16 16
17
18app.configure('production', function() { 17app.configure('production', function() {
19 app.listen(12445); 18 app.listen(12445);
20}); 19});
@@ -43,15 +42,13 @@ io.sockets.on('connection', function(socket) {
43 }; 42 };
44 43
45 socket.on('connect', function(data) { 44 socket.on('connect', function(data) {
46 45 // cambiar el servidor
47 var client = new irc.Client("localhost", data.nick, { 46 var client = new irc.Client("192.168.9.107", data.nick, {
48 debug: true, 47 debug: false,
49 showErrors: true, 48 showErrors: false,
50 channels: "lab", 49 channels: data.channels
51 port: 5000
52 }); 50 });
53 51
54
55 // Socket events sent FROM the front-end 52 // Socket events sent FROM the front-end
56 socket.on('join', function(name) { client.join(name); }); 53 socket.on('join', function(name) { client.join(name); });
57 socket.on('part', function(name) { client.part(name); }); 54 socket.on('part', function(name) { client.part(name); });
diff --git a/web-irc.js b/web-irc.js
deleted file mode 100644
index c30fdce..0000000
--- a/web-irc.js
+++ /dev/null
@@ -1,78 +0,0 @@
1#!/usr/bin/env node
2
3var express = require('express'),
4 app = express.createServer(),
5 io = require('socket.io').listen(app),
6 irc = require('irc');
7
8app.configure(function() {
9 app.use(app.router);
10 app.use(express.static(__dirname + '/public'));
11});
12
13app.configure('development', function() {
14 app.listen(8338);
15});
16
17app.configure('production', function() {
18 app.listen(12445);
19});
20
21app.get('/', function(req, res, next) {
22 next();
23});
24
25console.log('web-irc started on port %s', app.address().port);
26
27
28// Socket.IO
29io.sockets.on('connection', function(socket) {
30
31 // Events to signal TO the front-end
32 var events = {
33 'join': ['channel', 'nick'],
34 'part': ['channel', 'nick'],
35 'topic': ['channel', 'topic', 'nick'],
36 'nick': ['oldNick', 'newNick', 'channels'],
37 'names': ['channel', 'nicks'],
38 'message': ['from', 'to', 'text'],
39 'pm': ['nick', 'text'],
40 'motd': ['motd'],
41 'error': ['message']
42 };
43
44 socket.on('connect', function(data) {
45 var client = new irc.Client("192.168.9.107", data.nick, {
46 debug: false,
47 showErrors: false,
48 channels: data.channels
49 });
50
51 // Socket events sent FROM the front-end
52 socket.on('join', function(name) { client.join(name); });
53 socket.on('part', function(name) { client.part(name); });
54 socket.on('say', function(data) { client.say(data.target, data.message); });
55 socket.on('command', function(text) { console.log(text); client.send(text); });
56 socket.on('disconnect', function() { client.disconnect(); });
57
58
59 // Add a listener on client for the given event & argument names
60 var activateListener = function(event, argNames) {
61 client.addListener(event, function() {
62 console.log('Event ' + event + ' sent');
63 // Associate specified names with callback arguments
64 // to avoid getting tripped up on the other side
65 var callbackArgs = arguments;
66 args = {};
67 argNames.forEach(function(arg, index) {
68 args[arg] = callbackArgs[index];
69 });
70 console.log(args);
71 socket.emit(event, args);
72 });
73 };
74
75 for (var event in events) { activateListener(event, events[event]); }
76 console.log('Starting IRC client; wiring up socket events.')
77 });
78});