| 366 | } |
| 367 | |
| 368 | protected async _startSession(socket: net.Socket, telemetryReporter: ITelemetryReporter) { |
| 369 | if (!this.run) { |
| 370 | return; |
| 371 | } |
| 372 | |
| 373 | const { connection, cdp, targetInfo } = await this.acquireTarget( |
| 374 | socket, |
| 375 | telemetryReporter, |
| 376 | this.run.logger, |
| 377 | ); |
| 378 | if (!this.run) { |
| 379 | // if we aren't running a session, discard the socket. |
| 380 | socket.destroy(); |
| 381 | return; |
| 382 | } |
| 383 | |
| 384 | const target = new NodeTarget( |
| 385 | this.run.pathResolver, |
| 386 | this.run.context.targetOrigin, |
| 387 | connection, |
| 388 | cdp, |
| 389 | targetInfo, |
| 390 | this.run.logger, |
| 391 | this.createLifecycle(cdp, this.run, targetInfo), |
| 392 | ); |
| 393 | |
| 394 | target.setParent(targetInfo.openerId ? this.targets.get(targetInfo.openerId) : undefined); |
| 395 | this.targets.add(targetInfo.targetId, target); |
| 396 | target.onDisconnect(() => this.targets.remove(targetInfo.targetId)); |
| 397 | } |
| 398 | |
| 399 | /** |
| 400 | * Acquires the CDP session and target info from the connecting socket. |