     @_socket?.onmessage = (evnt) =>
       @fire 'mist:_socket.onmessage', arguments...
 
+      # "data":"{\"key\":\"value\", ... }"
       data = JSON.parse evnt.data
-      # "data":"{\"key\":\"value\", ... }"
-
       @fire 'mist:data', data
 
       #
       if error = data?.error then @fire 'mist:data.error', data.error
-
 
       ## handle mist commands
       if command = data?.command

  # close the websocket
  disconnect : () -> @_socket?.close()

  # subscribe attempts to subscribe the given tags
  subscribe : (tags=[]) ->
    if @is_connected() then @_socket?.send JSON.stringify( { command:'subscribe', tags:tags } )
    else @once "mist:_socket.onopen", (e) => @subscribe(tags)

          when 'unsubscribe' then @fire 'mist:command.unsubscribe', data
          when 'list'        then @fire "mist:command.subscriptions", data.subscriptions

      ## handle metadata; metadata is data that is specifically formatted to be
      # interpereted as "model" data. It will provide the name of a model, the
      # action the model is performing, and any related data.
      if data?.data

        #
        try

          # "data":"{\"data\":{\"model\":\"Model\",\"action\":\"update\", \"document\":{\"key\":\"value\", ...}}}"
          metadata = JSON.parse(data?.data)

          ## handle actions
          if action = metadata.action
            switch action
              when 'create' then @fire 'mist:metadata.action:create', data
              when 'update' then @fire 'mist:metadata.action:update', data
              when 'destroy' then @fire 'mist:metadata.action:destroy', data

        # this mostlikely happens when there IS data but its formatted incorrectly
        catch dash.error "Failed to parse data: #{metadata}"


    # return the open socket
    @_socket
