tencent cloud

Tencent Cloud Super App as a Service

Release Notes and Announcements
Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
Product Introduction
Overview
Strengths
Use Cases
Purchase Guide
Billing Overview
Pay-As-You-Go Billing
Renewal Guide
Service Suspension Instructions
Getting Started
Plan Management
Overview
Console Account Management
Storage Configuration
Acceleration Configuration
Branding Configurations
Platform Features
Console Login
Users and Permission System
Mini Program Management
Mini Game Management
Superapp Management
Commercialization
Platform Management
User Management
Team Management
Operations Management
Security Center
Code Integration Guide
Getting Demo and SDK
Android
iOS
Flutter
Superapp Server
GUID Generation Rules
Mini Program Development Guide
Mini Program Introduction and Development Environment
Mini Program Code Composition
Guide
Framework
Components
API
Server Backend
JS SDK
Base Library
IDE Operation Instructions
Mini Game Development Guide
Guide
API
Server Backend
Practice Tutorial
Mini Program Login Practical Tutorial
Mini Program Subscription Message Practical Tutorial
Payment Practical Tutorial
Ad Integration Practical Tutorial
Mini Game Subscription Message Practical Tutorial
API Documentation
History
Introduction
API Category
Making API Requests
Operation Management APIs
User Management APIs
Team Management APIs
Sensitive API-Related APIs
Role Management APIs
Platform Management APIs
Other Console APIs
Mini Program or Mini Game APIs
Management-Sensitive APIs
Global Domain Management APIs
Superapp APIs
Data Types
Agreements
Service Level Agreement
Data Processing and Security Agreement
SDK Privacy Policy Module
SDK Data Processing and Security Agreement Module

mDNS

PDF
Focus Mode
Font Size
Last updated: 2025-03-25 18:15:55

stopLocalServiceDiscovery

The method of utilizing this API is wx.stopLocalServiceDiscovery(Object object).
Function Description: Cease the exploration of mDNS services.
Parameters and Description: Object object.
Attributes
Types
Default value
Required
Note
success
function
-
Not required
Callback function for successful interface invocation
fail
function
-
Not required
Callback function for unsuccessful interface invocation
complete
function
-
Not required
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
object.fail Callback Function Parameters: Object res.
Attributes
Types
Note
errMsg
string
Error message, with the valid value being 'task not found': invoked when stopLocalServiceDiscovery is called while not currently in the search service.

startLocalServiceDiscovery

The usage method for this API is wx.startLocalServiceDiscovery(Object object)
Note:
For iOS, the integration of the TMFMiniAppExtMDNS extension library is required to use the mDNS related interfaces.
wx.startLocalServiceDiscovery is a performance-consuming action. It will automatically stop after 30 seconds and execute the callback function registered with wx.onLocalServiceDiscoveryStop.
After invoking wx.startLocalServiceDiscovery, the next wx.startLocalServiceDiscovery can only be initiated once this search action has ceased. Actions to halt this search include invoking wx.stopLocalServiceDiscovery and the system automatically stopping the search after 30 seconds.
Function Description: Initiates the search for mDNS services within the local area network. The results of the search will be returned via the wx.onLocalService* event.
Parameters and Description: Object object.
Attributes
Types
Default value
Required
Note
serviceType
string
-
Supported
The type of service to be searched for
success
function
-
Not required
Callback function for successful interface invocation
fail
function
-
Not required
Callback function for unsuccessful interface invocation
complete
function
-
Not required
Callback function executed upon the completion of the interface invocation (both successful and unsuccessful invocations)
object.fail callback function parameters: Object res.
Attributes
Types
Note
errMsg
string
Error message, valid values are
Invalid parameter: serviceType is empty.
Scan task already exists: startLocalServiceDiscovery is called again while the search initiated by the current startLocalServiceDiscovery has not stopped.
Example Code
wx.startLocalServiceDiscovery({
// There is a service of type _http._tcp. in the local area network connected to the current mobile phone.
serviceType: '_http._tcp.',
success: console.log,
fail: console.log
})

offLocalServiceResolveFail

The usage method for this API is wx.offLocalServiceResolveFail(function listener).
Function Description: Removes the listener function for the event of mDNS service resolution failure.
Parameters and Description: function listener, the listening function passed in by onLocalServiceResolveFail. If this parameter is not passed, all listening functions will be removed.
Sample Code:
const listener = function (res) { console.log(res) }

wx.onLocalServiceResolveFail(listener)
wx.offLocalServiceResolveFail(listener) // The same function object as the listener must be passed in.

onLocalServiceResolveFail

The usage method for this API is wx.onLocalServiceResolveFail(function listener).
Function Description: Monitors the event of mDNS service resolution failure.
Parameters and Description: function listener, the listener function for the event that the mDNS service fails to resolve, with the following arguments Object res:
Attributes
Types
Note
serviceType
string
Service Type
serviceName
string
Service Name

offLocalServiceLost

The usage method for this API is wx.offLocalServiceLost(function listener).
Function Description: Removes the listening function for the event of mDNS service departure.
Parameters and Description: function listener, the listener passed in by onLocalServiceLost. If you don't pass this parameter, you can remove all the listener functions.
Sample Code:
const listener = function (res) { console.log(res) }

wx.onLocalServiceLost(listener)
wx.offLocalServiceLost(listener) // The same function objct as used during listening must be passed in.

onLocalServiceLost

The usage method for this API is wx.onLocalServiceLost(function listener).
Function Description: Monitors the event of mDNS service departure.
Parameters and Description: function listener, the listener function for the event that the mDNS service leaves, with the following arguments Object res:
Attributes
Types
Note
serviceType
string
Service Type
serviceName
string
Service Name

offLocalServiceFound

The usage method for this API is wx.offLocalServiceFound(function listener).
Function Description: Removes the listening function for the event of mDNS service discovery.
Parameters and Description: function listener, onLocalServiceFound The listener function passed in. If this parameter is not passed, all listener functions are removed.
Sample Code:
const listener = function (res) { console.log(res) }

wx.onLocalServiceFound(listener)
wx.offLocalServiceFound(listener) // The same function object as the one used during monitoring needs to be passed in.

onLocalServiceFound

The usage method for this API is wx.onLocalServiceFound(function listener).
Function Description: Monitors the event of mDNS service discovery.
Parameters and Description: function listener, the listener function for events discovered by the mDNS service, with the following arguments Object res:
Attributes
Types
Note
serviceType
string
Service Type
serviceName
string
Service Name
ip
string
The IP address of the service.
port
number
The port of the service.

offLocalServiceDiscoveryStop

The usage method for this API is wx.offLocalServiceDiscoveryStop(function listener).
Function Description: Removes the listening function for the event of mDNS service stop discovery.
Parameters and Description: function listener, onLocalServiceDiscoveryStop The listener function passed in. If this parameter is not passed, all listener functions are removed.
Sample Code:
const listener = function (res) { console.log(res) }

wx.onLocalServiceDiscoveryStop(listener)
wx.offLocalServiceDiscoveryStop(listener) // The same function object as the listener must be passed in.

onLocalServiceDiscoveryStop

The usage method for this API is wx.onLocalServiceDiscoveryStop(function listener).
Function Description: Monitors the event of mDNS service stop discovery.
Parameters and Description: function listener, the listener function for the event that the mDNS service stops searching.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback