Khám phá lân cận
Kiểm tra app.capabilities để biết tính năng và app.access cùng quyền máy chủ để xác định quyền truy cập. Thay giá trị mẫu trước khi gọi.
Mỗi 2 giây, trang đọc isDiscovering và nearbyDevices trong một truy vấn GraphQL, cập nhật danh sách và chỉ gọi startDiscovery khi quét đã dừng. Khi đóng, trang gọi stopDiscovery bất kể các trang khác. Quét dừng sau năm phút kể từ lần khởi động cuối. BLE chạy riêng.
UDP → 224.0.0.251:5353PTR query
Đa hướng IPv4, không phải quảng bá IP: 224.0.0.251:5353. A duyệt mỗi 5 giây; B cũng công bố lúc khởi động và mỗi 60 giây. Trả lời PTR gồm SRV, TXT và A. Bản ghi DNS giả lập đã giải mã được hiển thị trong cửa sổ bật lên.
Định nghĩa kiểu
type Mutation {
acquireMdnsDebugSession(token: String!): Boolean!
releaseMdnsDebugSession(token: String!): Boolean!
startDiscovery: Boolean!
stopDiscovery: Boolean!
}
type Query {
isDiscovering: Boolean!
mdnsState: MdnsState!
nearbyDevices: [NearbyDevice!]!
parsePairingQrCode(code: String!): NearbyDevice
}
enum DeviceType {
COMPUTER
PHONE
TABLET
TV
NAS
OTHER
}
enum DiscoveryMethod {
LAN
BLE
QR
}
scalar Instant
scalar Long
type MdnsActivity {
time: Instant!
event: String!
detail: String!
}
type MdnsPacket {
time: Instant!
direction: MdnsPacketDirection!
srcIp: String!
srcPort: Int!
dstIp: String!
dstPort: Int!
size: Long!
summary: String!
detail: String!
}
enum MdnsPacketDirection {
IN
OUT
}
type MdnsService {
serviceType: String!
instanceName: String!
instanceFqdn: String!
hostname: String!
port: Int!
txtRecords: [String!]!
ips: [String!]!
ip6s: [String!]!
complete: Boolean!
}
type MdnsState {
runtimeId: String!
packetsIn: [MdnsPacket!]!
packetsOut: [MdnsPacket!]!
revision: Long!
running: Boolean!
scanning: Boolean!
services: [MdnsService!]!
activity: [MdnsActivity!]!
}
type NearbyDevice {
id: ID!
name: String!
ips: [String!]!
port: Int!
remoteAccess: Boolean
signaturePublicKey: String!
deviceType: DeviceType!
version: String!
platform: String!
discoveryMethods: [DiscoveryMethod!]!
bestIp: String!
status: PeerStatus!
lastSeen: Instant!
}
enum PeerStatus {
PAIRED
UNPAIRED
CHANNEL
}Thao tác
acquireMdnsDebugSession
Tạo phiên gỡ lỗi mDNS bằng mã UUID của bên gọi. Cần HTTP_SERVER; giải phóng phiên khi đóng trang gỡ lỗi.
mutation acquireMdnsDebugSession($token: String!) {
acquireMdnsDebugSession(token: $token)
}releaseMdnsDebugSession
Giải phóng phiên gỡ lỗi mDNS bằng mã tương ứng. Cần HTTP_SERVER.
mutation releaseMdnsDebugSession($token: String!) {
releaseMdnsDebugSession(token: $token)
}startDiscovery
Bắt đầu khám phá thiết bị.
mutation startDiscovery {
startDiscovery
}stopDiscovery
Dừng khám phá thiết bị.
mutation stopDiscovery {
stopDiscovery
}isDiscovering
Cho biết quét khám phá có đang chạy hay không.
query isDiscovering {
isDiscovering
}mdnsState
Đọc trạng thái khám phá mDNS hiện tại và thông tin dịch vụ hoặc gói được chọn.
query mdnsState {
mdnsState { runtimeId revision running scanning }
}nearbyDevices
Liệt kê thiết bị lân cận hiện biết có thể khám phá hoặc ghép đôi.
query nearbyDevices {
nearbyDevices { id name ips port remoteAccess signaturePublicKey deviceType version }
}parsePairingQrCode
Giải mã mã ghép đôi hợp lệ thành thông tin kết nối thiết bị lân cận.
query parsePairingQrCode($code: String!) {
parsePairingQrCode(code: $code) { id name ips port remoteAccess signaturePublicKey deviceType version }
}