 # This is an implementation of _debugger that talks to the DartVM
 # over websockets. _debugger is part of the internal atom repl.js
-# package.
+# package. The rest of the debugger code (e.g., flutter-debugger.coffee)
+# is looking for the following methods:
 
 # .client.destroy
 # .client.reqLookup(ref)

    @s.onmessage = (event) =>
      logger.info 'shim', 'ws::onmessage'
      json = JSON.parse(event.data)
      if (json.id == 'stream_debug')
        console.log(json)
        logger.info 'shim', event.data
      if (json.id == 'stream_iso')
        console.log(json)
        logger.info 'shim', event.data
      else if (json.id == 'getvm')
        @vm = json.result

        # collect detailed isolate info so we can set breakpoints/etc.
        @s.send('{"jsonrpc": "2.0","method": "getIsolate","params":{"isolateId":"'+iso.id+'"},"id": "getiso"}') for iso in json.result.isolates

        @emit 'ready'
      else if (json.id == 'getiso')
        isolate = json.result;

        @isolates[isolate.id] = isolate
        console.log 'the ISO object ' + isolate.id
        #console.log(@isolates)

        # also collect the 'scripts' for this isolate
        @s.send('{"jsonrpc": "2.0","method": "getObject","params":{"isolateId":"'+isolate.id+'",\
            "objectId":"'+lib.id+'"},"id": "getlib"}') for lib in isolate.libraries

      else if (json.id == 'getlib')
        # callback for asking for library details. We'll need this to
        # set breakpoints on the script.
        lib = json.result;
        @libraries[lib.id] = lib

        #console.log @libraries
      else
        console.log("ws::message (unclassified) " + event.data)


    @s.onclose = () =>

      "scriptId":"'+scriptId+'", \
      "line":'+req.line.toString()+' \
      },"id":"addbreakpoint"}'
    #console.log str
    @s.send str


