appium-remote-debugger
Version:
Appium proxy for Remote Debugger protocol
68 lines • 2.33 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.RpcClientRealDevice = void 0;
const logger_1 = require("../logger");
const rpc_client_1 = require("./rpc-client");
const appium_ios_device_1 = require("appium-ios-device");
/**
* RPC client implementation for real iOS devices.
* Extends RpcClient to provide device-specific connection handling.
*/
class RpcClientRealDevice extends rpc_client_1.RpcClient {
service;
/**
* Connects to the Web Inspector service on a real iOS device.
* Starts the Web Inspector service and sets up message listening.
*/
async connect() {
if (this.isConnected) {
return;
}
this.service = await appium_ios_device_1.services.startWebInspectorService(this.udid, {
osVersion: this.platformVersion,
isSimulator: false,
verbose: this.logAllCommunication,
verboseHexDump: this.logAllCommunicationHexDump,
socketChunkSize: this.socketChunkSize,
maxFrameLength: this.webInspectorMaxFrameLength,
});
this.service.listenMessage(this.receive.bind(this));
this.isConnected = true;
}
/**
* Disconnects from the Web Inspector service on the real device.
* Closes the service connection and cleans up resources.
*/
async disconnect() {
if (!this.isConnected) {
return;
}
logger_1.log.debug('Disconnecting from remote debugger');
await super.disconnect();
this.service?.close();
this.isConnected = false;
}
/**
* Sends a command message to the Web Inspector service.
*
* @param cmd - The command to send to the device.
*/
async sendMessage(cmd) {
if (!this.service) {
throw new Error('RPC service is not initialized. Is the client connected?');
}
this.service.sendMessage(cmd);
}
/**
* Receives data from the Web Inspector service and handles it.
*
* @param data - The data received from the service.
*/
async receive(data) {
if (this.isConnected) {
await this.messageHandler.handleMessage(data);
}
}
}
exports.RpcClientRealDevice = RpcClientRealDevice;
//# sourceMappingURL=rpc-client-real-device.js.map