40 lines
750 B
CoffeeScript
40 lines
750 B
CoffeeScript
|
# libraries
|
||
|
http = require 'http'
|
||
|
socketio = require 'socket.io'
|
||
|
express = require 'express'
|
||
|
gulp = global.gulp = require 'gulp'
|
||
|
helmet = require 'helmet'
|
||
|
|
||
|
# gulp the sources
|
||
|
require './gulpfile'
|
||
|
gulp.start 'default'
|
||
|
|
||
|
# socket.io framework
|
||
|
app = express()
|
||
|
web = http.Server app
|
||
|
io = socketio web
|
||
|
|
||
|
# Listen server
|
||
|
web.listen 8080, ->
|
||
|
console.log 'Node.js listening on port 8080'
|
||
|
|
||
|
app.use helmet()
|
||
|
|
||
|
# Static content
|
||
|
app.use ( express.static __dirname + '/../static' )
|
||
|
|
||
|
# Server logic
|
||
|
io.on 'connection', (socket) ->
|
||
|
console.log 'a user connected'
|
||
|
console.log socket.id
|
||
|
|
||
|
socket.on 'disconnect', ->
|
||
|
# console.log 'user disconnected'
|
||
|
return
|
||
|
|
||
|
socket.on 'login', ->
|
||
|
console.log 'message:', msg.uname, msg.password
|
||
|
return
|
||
|
|
||
|
return
|