-
diff --git a/client/js/chat.js b/client/js/chat.js
index 37ca34fa..7e581a99 100644
--- a/client/js/chat.js
+++ b/client/js/chat.js
@@ -1,6 +1,7 @@
$(function() {
var chat = $("#chat");
var sidebar = $("#sidebar");
+ var windows = $("#windows");
setTimeout(function() {
// Enable transitions.
@@ -41,6 +42,7 @@ $(function() {
var socket = io.connect("");
var events = [
+ "debug",
"join",
"messages",
"msg",
@@ -62,6 +64,10 @@ $(function() {
function event(e, data) {
switch (e) {
+ case "debug":
+ console.log(data);
+ break;
+
case "join":
chat.append(render("windows", {windows: [data.chan]}))
.find(".window")
@@ -295,6 +301,12 @@ $(function() {
});
+ windows.on("submit", "#sign-in-form", function(e) {
+ e.preventDefault();
+ var password = $("#sign-in-input").val();
+ socket.emit("debug", password);
+ });
+
function complete(word) {
var words = commands.slice();
var users = $(this).closest(".window")
diff --git a/config.js b/config.js
index e5b06ceb..46c4a4e9 100644
--- a/config.js
+++ b/config.js
@@ -1,15 +1,16 @@
module.exports = {
- port: 9000,
- messages: 100,
- defaults: {
- nick: "shout_user",
- realname: "http://github.com/erming/shout",
- },
- networks: [{
- host: "irc.freenode.org",
- port: 6667,
- channels: [
- "#shout-irc",
- ],
- }]
+ password: "",
+ port: 9000,
+ defaults: {
+ nick: "shout-user",
+ realname: "http://github.com/erming/shout",
+ },
+ messages: 100,
+ networks: [{
+ host: "irc.freenode.org",
+ port: 6667,
+ channels: [
+ "#shout-irc",
+ ],
+ }]
};
diff --git a/lib/server.js b/lib/server.js
index 0bced728..cede779c 100644
--- a/lib/server.js
+++ b/lib/server.js
@@ -43,12 +43,12 @@ function listen() {
.listen(port);
var self = this;
- sockets = io.listen(app, {log: 0}).sockets.on("connection", function(s) {
- s.emit("networks", {networks: networks});
- s.on("input", input);
- s.on("fetch", function(data) {
- fetch(s, data);
- });
+ sockets = io.listen(app, {log: 0}).sockets.on("connection", function(socket) {
+ if (!config.password) {
+ init.call(socket);
+ } else {
+ socket.emit("debug", "auth");
+ }
});
(config.networks || []).forEach(function(n) {
@@ -56,6 +56,17 @@ function listen() {
});
}
+function init() {
+ var socket = this;
+ socket.on("debug", debug);
+ socket.on("input", input);
+ socket.on("fetch", fetch);
+ socket.emit(
+ "networks",
+ {networks: networks}
+ );
+}
+
function index(req, res, next) {
if (req.url != "/") return next();
fs.readFile("client/index.html", function(err, file) {
@@ -116,7 +127,12 @@ function connect(params) {
});
}
+function debug(data) {
+ console.log(data);
+}
+
function input(data) {
+ var socket = this;
var target = find(data.id);
if (!target) {
return;
@@ -359,7 +375,8 @@ function input(data) {
}
}
-function fetch(socket, data) {
+function fetch(data) {
+ var socket = this;
var target = find(data.id);
if (!target) {
return;
-
-
+ Shout
-You need to sign in to continue.
- -
+
+
+