* Begin an RTM session using the provided options. This method must be called before any messages can * be sent or received.
(options?: RTMStartOptions)
| 373 | * be sent or received. |
| 374 | */ |
| 375 | public start(options?: RTMStartOptions): Promise<WebAPICallResult> { |
| 376 | this.logger.debug('start()'); |
| 377 | |
| 378 | // capture options for potential future reconnects |
| 379 | this.startOpts = options; |
| 380 | |
| 381 | // delegate behavior to state machine |
| 382 | this.stateMachine.handle('start'); |
| 383 | |
| 384 | // return a promise that resolves with the connection information |
| 385 | return new Promise((resolve, reject) => { |
| 386 | this.once('authenticated', (result) => { |
| 387 | this.removeListener('disconnected', reject); |
| 388 | resolve(result); |
| 389 | }); |
| 390 | this.once('disconnected', (err) => { |
| 391 | this.removeListener('authenticated', resolve); |
| 392 | reject(err); |
| 393 | }); |
| 394 | }); |
| 395 | } |
| 396 | |
| 397 | /** |
| 398 | * End an RTM session. After this method is called no messages will be sent or received unless you call |
no test coverage detected