Skip to main content

AndroidSocket

AndroidSocket 是一种与 AndroidDevice 上启动的进程进行通信的方式。使用 androidDevice.open() 打开套接字。

AndroidSocket is a way to communicate with a process launched on the AndroidDevice. Use androidDevice.open() to open a socket.


方法

Methods

close

Added in: v1.9 androidSocket.close

关闭套接字。

Closes the socket.

用法

Usage

await androidSocket.close();

write

Added in: v1.9 androidSocket.write

将一些 data 写入套接字。

Writes some data to the socket.

用法

Usage

await androidSocket.write(data);

参数

Arguments

要写入的数据。

Data to write.


事件

Events

on('close')

Added in: v1.9 androidSocket.on('close')

当套接字关闭时触发。

Emitted when the socket is closed.

用法

Usage

androidSocket.on('close', data => {});

on('data')

Added in: v1.9 androidSocket.on('data')

当数据可从套接字读取时触发。

Emitted when data is available to read from the socket.

用法

Usage

androidSocket.on('data', data => {});

事件数据

Event data