             command: 'close'
             text: 'instance closed'
         client = @clientList.get uid
-        #socketController.sendAll obj, uid
         super uid
     get: (uid) ->
         #console.log "getting instances with id: #{id}"

    constructor: ->
        @masterSocket = io.listen server
        @instanceList = new Instances
        @masterSocket.on 'connection', (clientSocket) =>
            #console.log clientSocket
            @instanceList.add clientSocket.sessionId, clientSocket
            #clientList.add clientSocket.sessionId, clientSocket

            clientSocket.on 'message', (data) =>
                console.log "<<< receiving #{data}"
                obj = jsonController.getObject data
                action = obj.action
                uid = obj.uid
                client = @instanceList.clientList.get uid
                #console.log client if client?
                (client[action])(obj, @instanceList.spriteList) if client?
                #console.log "ran command: #{action}"
            clientSocket.on 'disconnect', =>
                @instanceList.clientList.remove clientSocket.sessionId
                @instanceList.spriteList.removeAllOfUser clientSocket.sessionId
                console.log 'disconnecting'

            #send init function to this client to initialize interface
            obj =
                command:'init'
                uid:clientSocket.sessionId
                text: 'initializing new client'
            socketController.send clientSocket, obj

            #send all existing sprites to the new client
            sprites = @instanceList.spriteList.getAll()
            for id of sprites
                sprite = @instanceList.spriteList.get id
                obj =
                    command: 'create'
                    uid: sprite.getUid()
                    id: sprite.getId()


class Clients extends Hash
    add: (uid, clientSocket) ->
        console.log "adding client with uid: #{uid}"
        client = new Client uid, clientSocket
        super uid, client
        client
    remove: (uid) ->
        #console.log "removing client with uid: #{uid}"
        obj =
