Bug 919681 - Remove duplicate simulator connected handlers. r=ochameau

This commit is contained in:
J. Ryan Stinnett 2013-09-23 14:25:10 -05:00
parent 82c1d66218
commit fdb80c5b40

View File

@ -61,6 +61,9 @@ let UI = {
this.template = new Template(document.body, this.store, Utils.l10n);
this.template.start();
this._onSimulatorConnected = this._onSimulatorConnected.bind(this);
this._onSimulatorDisconnected = this._onSimulatorDisconnected.bind(this);
},
useFloatingScrollbarsIfNeeded: function() {
@ -136,16 +139,25 @@ let UI = {
this.connection.log("Simulator ready. Connecting.");
this.connection.port = port;
this.connection.host = "localhost";
this.connection.once("connected", () => {
this.connection.log("Connected to simulator.");
this.connection.keepConnecting = false;
});
this.connection.once("connected",
this._onSimulatorConnected);
this.connection.once("disconnected",
this._onSimulatorDisconnected);
this.connection.keepConnecting = true;
this.connection.connect();
});
document.body.classList.remove("show-simulators");
},
_onSimulatorConnected: function() {
this.connection.log("Connected to simulator.");
this.connection.keepConnecting = false;
},
_onSimulatorDisconnected: function() {
this.connection.off("connected", this._onSimulatorConnected);
},
connectToAdbDevice: function(name) {
let device = Devices.getByName(name);
device.connect().then((port) => {