Skip to content

Instantly share code, notes, and snippets.

Created June 7, 2013 14:57
Show Gist options
  • Save anonymous/8e4c540521e8117823b6 to your computer and use it in GitHub Desktop.
Save anonymous/8e4c540521e8117823b6 to your computer and use it in GitHub Desktop.
class User
constructor: (@username, @rank, @roll, @hero, @steamurl, @socket) ->
class Room
constructor: (owner) ->
@occupants = []
sendMsg: (msg, user) ->
for client in @occupants
io.sockets.socket(client.socket).emit 'updateChat', 'user': user, 'msg': msg
checkDoubles: (user) ->
returnVal = false
for client in @occupants
if client.username is user
returnVal = true
returnVal
leaveRoom: (user) ->
@occupants.forEach (client, index, arr) ->
if client.username is user
arr.splice index, 1
getUsers: () ->
returnOccupants = []
@occupants.forEach (client, index, arr) ->
returnOccupants.push client.username
returnOccupants
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment