停止搜索 mDNS 服务
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| errMsg | string | 错误信息 |
res.errMsg 的合法值
| 值 | 说明 |
|---|---|
| task not found | 在当前没有处在搜索服务中的情况下调用 stopLocalServiceDiscovery |
开始搜索局域网下的 mDNS 服务。搜索的结果会通过 qq.onLocalService* 事件返回。
| 属性 | 类型 | 默认值 | 必填 | 说明 |
|---|---|---|---|---|
| serviceType | string | 是 | 要搜索的服务类型 | |
| success | function | 否 | 接口调用成功的回调函数 | |
| fail | function | 否 | 接口调用失败的回调函数 | |
| complete | function | 否 | 接口调用结束的回调函数(调用成功、失败都会执行) |
参数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| errMsg | string | 错误信息 |
res.errMsg 的合法值
| 值 | 说明 |
|---|---|
| invalid param | serviceType 为空 |
| scan task already exist | 在当前 startLocalServiceDiscovery 发起的搜索未停止的情况下,再次调用 startLocalServiceDiscovery |
qq.startLocalServiceDiscovery({
// 当前手机所连的局域网下有一个 _http._tcp. 类型的服务
serviceType: '_http._tcp.',
success: console.log,
fail: console.log
})
监听 mDNS 服务解析失败的事件
mDNS 服务解析失败的事件的回调函数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| serviceType | string | 服务的类型 |
| serviceName | string | 服务的名称 |
监听 mDNS 服务离开的事件
mDNS 服务离开的事件的回调函数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| serviceType | string | 服务的类型 |
| serviceName | string | 服务的名称 |
监听 mDNS 服务发现的事件
mDNS 服务发现的事件的回调函数
Object res
| 属性 | 类型 | 说明 |
|---|---|---|
| serviceType | string | 服务的类型 |
| serviceName | string | 服务的名称 |
| ip | string | 服务的 ip 地址 |
| port | number | 服务的端口 |
监听 mDNS 服务停止搜索的事件
mDNS 服务停止搜索的事件的回调函数
取消监听 mDNS 服务解析失败的事件
mDNS 服务解析失败的事件的回调函数
取消监听 mDNS 服务离开的事件
mDNS 服务离开的事件的回调函数
取消监听 mDNS 服务发现的事件
mDNS 服务发现的事件的回调函数
取消监听 mDNS 服务停止搜索的事件
mDNS 服务停止搜索的事件的回调函数