 
         socket.addEventListener "close", ->
             console.log "Client disconnected"
-            return
-        return
-    return
 
 uploadGraphFromFile = (graphPath, serialPortName, baudRate, debugLevel) ->
     serial.openTransport serialPortName, baudRate, (err, transport) ->
         loadFile graphPath, (err, graph) ->
             data = commandstream.cmdStreamFromGraph(componentLib, graph, debugLevel)
             uploadGraph transport, data, graph
-            return
-        return
-    return
 
 module.exports =
     loadFile: loadFile

    outputDir = path.dirname(outputBase)
    fs.mkdirSync outputDir    unless fs.existsSync(outputDir)
    loadFile inputFile, (err, def) ->
        throw err    if err
        
        # TODO: allow to generate just one of these
        fs.writeFile outputBase + ".json", JSON.stringify(def), (err) ->
            throw err    if err
            return

        data = commandstream.cmdStreamFromGraph(componentLib, def)
        fs.writeFile outputBase + ".fbcs", data, (err) ->
            throw err    if err
            return

        fs.writeFile outputBase + ".h", generate.cmdStreamToCDefinition(data, target), (err) ->
            throw err    if err
            return

        fs.writeFile outputFile, generate.cmdStreamToCDefinition(data, target) + "\n" + "#define MICROFLO_EMBED_GRAPH\n" + "#include \"microflo.h\"" + "\n#include \"main.hpp\"", (err) ->
            throw err    if err
            return

        return

    return


# TODO: Use noflo.graph.loadFile() instead?
loadFile = (filename, callback) ->
    fs.readFile filename,
        encoding: "utf8"
    , (err, data) ->
        callback err    if err
        def = undefined
        if path.extname(filename) is ".fbp"
            def = fbp.parse(data)
        else
            def = JSON.parse(data)
        callback `undefined`, def
        return

    return


# TODO: allow port types to be declared in component metadata,

                    contents = JSON.parse(message.utf8Data)
                catch e
                    console.log "WS parser error: ", e
                
                # Only expose a narrow API for communicating back to UI
                sendFunc = (response) ->
                    connection.sendUTF JSON.stringify(response)
                conn = send: sendFunc
                handleMessage contents, conn, graph, getSerial, debugLevel

    httpServer.listen port, ip, (err) ->
        error err if err
        console.log "MicroFlo runtime listening at", ip + ":" + port

setupRuntimeChrome = (serialPortToUse, baudRate, port, debugLevel, ip) ->
    throw new Error("Cannot load Chrome HTTP/WebSockets API")    unless http.Server and http.WebSocketServer
