This repository has been archived on 2024-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
node-fftcg/backend/socket.coffee

32 lines
735 B
CoffeeScript

# node libraries
socketio = (require 'socket.io')
path = (require 'path')
logger = (require 'logging').default 'socket'
# my libraries
FFTCGSOCKET = (http, session) ->
that = @
# create server socket
@io = socketio http
@io.use session
# on new connection
@io.on 'connection', (socket) ->
@session = socket.handshake.session
logger.debug "session '#{@session.id}' connected"
logger.debug "is user '#{@session.userID}'" if @session.userID
socket.on 'disconnect', ->
logger.debug "session '#{that.session.id}' disconnected"
logger.debug "is user '#{that.session.userID}'" if that.session.userID
return
FFTCGSOCKET::close = ->
logger.info 'shutting down'
module.exports = FFTCGSOCKET