Tham chiếu API

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.

Device A
UDP → 224.0.0.251:5353
Device B

PTR query

UDP · DNS

Đ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.

Di chuột hoặc chạm một trường
1 / 3

Định nghĩa kiểu

graphql
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

mutation

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.

graphql
mutation acquireMdnsDebugSession($token: String!) {
  acquireMdnsDebugSession(token: $token)
}
mutation

releaseMdnsDebugSession

Giải phóng phiên gỡ lỗi mDNS bằng mã tương ứng. Cần HTTP_SERVER.

graphql
mutation releaseMdnsDebugSession($token: String!) {
  releaseMdnsDebugSession(token: $token)
}
mutation

startDiscovery

Bắt đầu khám phá thiết bị.

graphql
mutation startDiscovery {
  startDiscovery
}
mutation

stopDiscovery

Dừng khám phá thiết bị.

graphql
mutation stopDiscovery {
  stopDiscovery
}
query

isDiscovering

Cho biết quét khám phá có đang chạy hay không.

graphql
query isDiscovering {
  isDiscovering
}
query

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.

graphql
query mdnsState {
  mdnsState { runtimeId revision running scanning }
}
query

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.

graphql
query nearbyDevices {
  nearbyDevices { id name ips port remoteAccess signaturePublicKey deviceType version }
}
query

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.

graphql
query parsePairingQrCode($code: String!) {
  parsePairingQrCode(code: $code) { id name ips port remoteAccess signaturePublicKey deviceType version }
}