code: function emit(eventName, id, args) {
    var js = "function () { window.socket.emit(\"" + eventName + "\"";
  
    // we're assuming args is an array of function arguments
    // if not, wrap it
    if (!(args instanceof Array)) {
      args = [args];
    }
  
    if (id) {
      js += ", " + id + ", " + JSON.stringify(args);
    }
  
    js += ");}";
  
    controlPage.evaluate(js);
  }
docs: /*
  This uses a websockets method heavily inspired by Alex Scheel Meyer's node-phantom
  https://github.com/alexscheelmeyer/node-phantom
  
  for a bit more explanation as to what's going on
  see the comments in lib/bridge.js