Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
organizing app into public & server containers - moving socket to doo…
…dle namespace
- Loading branch information
Stephen Braitsch
committed
Jun 14, 2012
1 parent
fbeb467
commit 38fcd21
Showing
21 changed files
with
58 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
|
||
module.exports = function(app, exp) { | ||
|
||
app.configure(function(){ | ||
app.set('views', app.root + '/app/server/views'); | ||
app.set('view engine', 'jade'); | ||
app.set('view options', { doctype : 'html', pretty : true }); | ||
app.use(exp.bodyParser()); | ||
app.use(exp.methodOverride()); | ||
app.use(require('stylus').middleware({ src: app.root + '/app/public' })); | ||
app.use(exp.static(app.root + '/app/server')); | ||
app.use(exp.static(app.root + '/app/public')); | ||
}); | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
File renamed without changes.
File renamed without changes.
File renamed without changes
File renamed without changes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
|
||
|
||
module.exports = function() | ||
{ | ||
|
||
var connections = { }; | ||
|
||
global.socket.of('/doodle').on('connection', function(socket) { | ||
socket.on('draw-data', function(data) { | ||
// append this socket's id so we know who is talking // | ||
data.id = socket.id; | ||
socket.broadcast.emit('draw-data', data); | ||
}); | ||
|
||
function dispatchStatus() | ||
{ | ||
brodcastMessage('status', connections); | ||
} | ||
|
||
function brodcastMessage(message, data) | ||
{ | ||
// remove socket.emit if you don't want the sender to receive their own message // | ||
socket.emit(message, data); | ||
socket.broadcast.emit(message, data); | ||
} | ||
|
||
// handle connections & disconnections // | ||
connections[socket.id] = {}; dispatchStatus(); | ||
socket.on('disconnect', function() { | ||
delete connections[socket.id]; dispatchStatus(); | ||
}); | ||
|
||
}); | ||
}(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
|
||
require('./modules/doodle-socket'); | ||
|
||
module.exports = function(app) { | ||
|
||
app.get('/', canvas); | ||
|
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.