()
| 49 | } |
| 50 | |
| 51 | async start() { |
| 52 | const [controlPort, streamPort] = await findFreePorts(2); |
| 53 | this.controlPort = controlPort; |
| 54 | this.streamPort = streamPort; |
| 55 | /** |
| 56 | * start tunnel for control port |
| 57 | */ |
| 58 | try { |
| 59 | await this.tunnelManager.startControlTunnel(controlPort); |
| 60 | } catch (error) { |
| 61 | logger.error(`error start tunnel for control port`, error); |
| 62 | await this.stop(); |
| 63 | return false; |
| 64 | } |
| 65 | |
| 66 | /** |
| 67 | * start tunnel for stream port |
| 68 | */ |
| 69 | try { |
| 70 | await this.tunnelManager.startStreamTunnel(streamPort); |
| 71 | } catch (error) { |
| 72 | logger.error(`error start tunnel for stream port`, error); |
| 73 | await this.stop(); |
| 74 | return false; |
| 75 | } |
| 76 | |
| 77 | /** |
| 78 | * start webdriveragent |
| 79 | */ |
| 80 | try { |
| 81 | this.wdaGoIOS = new WdaGoIOS(this.udid, this.version, controlPort, streamPort); |
| 82 | await this.wdaGoIOS.start(); |
| 83 | } catch (error) { |
| 84 | logger.error(`error start tunnel for stream port`, error); |
| 85 | await this.stop(); |
| 86 | return false; |
| 87 | } |
| 88 | |
| 89 | /** |
| 90 | * start stream |
| 91 | */ |
| 92 | try { |
| 93 | await this.wdaStreamClient.connect(streamPort); |
| 94 | await this.wdaStreamClient.startProcessing(); |
| 95 | } catch (error) { |
| 96 | logger.error(`error start tunnel for stream port`, error); |
| 97 | await this.stop(); |
| 98 | return false; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * start wda control |
| 103 | */ |
| 104 | try { |
| 105 | this.wdaControlClient = new WdaControlClient(controlPort); |
| 106 | await this.wdaControlClient.createWdaSession(); |
| 107 | } catch (error) { |
| 108 | logger.error(`error creating wda control client`, error); |
no test coverage detected