Skip to content

Commit

Permalink
colocando o websocket finalmente para funcionar
Browse files Browse the repository at this point in the history
  • Loading branch information
aoqfonseca committed Apr 5, 2012
1 parent d80e5cd commit eb1cafe
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 10 deletions.
26 changes: 17 additions & 9 deletions app.coffee
Original file line number Diff line number Diff line change
@@ -1,39 +1,47 @@
express = require 'express'
app = express.createServer();

io = require 'socket.io'
appSocketIO = io.listen(app)

## Configurations
app.configure ->
app.use express.methodOverride()
app.use express.bodyParser()
app.use express.methodOverride()
app.use express.bodyParser()
app.use app.router
app.set 'views', "#{__dirname}/views"
app.set 'view engine', 'jade'
app.use express.cookieParser();
app.use express.session({secret : "churupita" })
app.use express.session({secret : "churupita" })
app.use express.static(__dirname + '/public')


## Dev configs
app.configure 'development', ->
## Dev configs
app.configure 'development', ->
app.use express.errorHandler({ dumpExceptions: true, showStack: true })


##Prod configs
app.configure 'prod', ->
app.use express.errorHandler()
app.configure 'prod', ->
app.use express.errorHandler()

#middleware for auth
has_permission = (req,res, next) ->
has_permission = (req,res, next) ->
next()
# if res.session.user? and res.session.user=='chefe'
# next()
# else
# res.redirect('/error_invalid.html')

##Routes
app.get "/speaker", has_permission, (req, res) ->
app.get "/speaker", has_permission, (req, res) ->
res.render 'speaker'

##Websockets parts
appSocketIO.on 'connection', (client) ->
client.on 'paginate', (pag) ->
appSocketIO.broadcast.emit('changePage', pag)


## start server to listening */
app.listen 3000
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name" : "NodeKeynote",
"version" : "0.0.1",
"version" : "0.0.5",
"description" : "Project to create an keynote node presenter",
"homepage" : [ "https://github.com/aoqfonseca/nodekeynote"],
"repository" : { "type" : "git", "url" : "https://github.com/aoqfonseca/nodekeynote"},
Expand Down

0 comments on commit eb1cafe

Please sign in to comment.