# wx.startLocalServiceDiscovery(Object object)

Start from base library version 2.4.0. Please remaining backward compatible.

with Promise style call: Supported

Mini Program plugin: Support, need to Mini Program base library version no less than 2.15.0

Start searching the LAN. mDNS Service. The results of the search are passed through wx.onLocalService* Event returns.

# parameter

# Object object

attribute type Default values Required Introductions
serviceType string yes Type of service to search for
success function no Interface calls the successful callback function
fail function no Interface calls failed callback functions
complete function no Callback function at the end of an interface call (both successful and unsuccessful calls are executed)

# object.fail callback

# parameter
# Object res
attribute type Introductions
errMsg string Error message

res.errMsg Legal value

value Introductions Minimum version
invalid param serviceType Empty
scan task already exist In the present startLocalServiceDiscovery Is called again without stopping the search initiated startLocalServiceDiscovery

# sample code


    wx.startLocalServiceDiscovery({
      // The LAN that the phone is currently connected to has a _http._tcp. Type of service
      serviceType: '_http._tcp.',
      success: console.log,
      fail: console.log
    })

# Be careful

  1. Due to changes in operating system-related capabilities, iOS WeChat Client 7.0.18 The version above is not available mDNS Related interfaces, Android version not affected
  2. wx.startLocalServiceDiscovery Is a performance-consuming behavior. Here we go. 30 After seconds, it will automatically stop And execute wx.onLocalServiceDiscoveryStop Registered callback function.
  3. In calling wx.startLocalServiceDiscovery In this search behavior to stop before launching the next wx.startLocalServiceDiscovery。 Stopping this search behavior involves calling the wx.stopLocalServiceDiscovery and 30 Seconds after automatic system stop This search.