summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJules Laplace <jules@okfoc.us>2013-02-26 10:24:33 -0500
committerJules Laplace <jules@okfoc.us>2013-02-26 10:24:33 -0500
commit0f384052418447aa342b38c8df3b6a8a48c245ae (patch)
tree988610712787e06772caa107d22b8945edecfc0c
parentf031288fbd95ebb47729835a2930d0266482adcf (diff)
small event changes..
-rw-r--r--public/css/chat.css2
-rw-r--r--public/js/draw.js1
-rw-r--r--public/js/game.js2
-rw-r--r--server.js23
4 files changed, 17 insertions, 11 deletions
diff --git a/public/css/chat.css b/public/css/chat.css
index 9805a86..dea2dc1 100644
--- a/public/css/chat.css
+++ b/public/css/chat.css
@@ -14,7 +14,7 @@
width: 250px;
}
#chat #chat_shim {
- height: 390px;
+ height: 310px;
}
#chat p {
margin: 0;
diff --git a/public/js/draw.js b/public/js/draw.js
index d97dba1..786b6b6 100644
--- a/public/js/draw.js
+++ b/public/js/draw.js
@@ -27,6 +27,7 @@ $(function(){
drawing = false;
lastpoint = null;
}
+ $("#chat-message").focus();
});
function clearWorkspace(){
workspaceCtx.fillStyle = "#fff";
diff --git a/public/js/game.js b/public/js/game.js
index c348e9a..010f01f 100644
--- a/public/js/game.js
+++ b/public/js/game.js
@@ -6,7 +6,9 @@ var Game = {
init: function(){
// Bind events from the server
+ socket.on('event-welcome', Events.receive.join);
socket.on('event-join', Events.receive.join);
+ socket.on('event-part', Events.receive.join);
socket.on('event-message', Events.receive.message);
socket.on('event-image', Events.receive.image);
Auth.init();
diff --git a/server.js b/server.js
index a16ad84..801b68d 100644
--- a/server.js
+++ b/server.js
@@ -65,21 +65,19 @@ var State = {
function Channel() {
this.state = State.WAITING;
this.messages = [];
+ this.images = {};
+ this.imageCount = 0;
this.players = {};
this.message_id = 0;
}
+Channel.prototype.join = function(user){
+ // socket.id
+}
Channel.prototype.push = function(message){
if (this.messages.length > 20) this.messages.shift();
this.messages.push(message);
}
-Channel.prototype.fave = function(id){
- for (var i = 0; i < messages.length; i++) {
- if (messages[i].id == id) {
- messages[i].faves++;
- }
- }
-}
-Channel.prototype.join = function(){
+Channel.prototype.report = function(){
return {
state: this.state,
messages: this.messages,
@@ -87,14 +85,19 @@ Channel.prototype.join = function(){
}
}
-
var game = new Channel ();
io.sockets.on( 'connection', function(socket){
- socket.emit( 'event-join', game.join() );
+ socket.emit( 'event-welcome', game.report() );
+ socket.on( 'event-join', function(data){
+ socket.broadcast.emit('event-join', data);
+ } );
socket.on( 'event-message', function(data){
game.push(data);
socket.broadcast.emit('event-message', data);
} );
+ socket.on( 'disconnect', function(data){
+ socket.broadcast.emit('event-part', data);
+ } );
});
/******************************* DONE