import Vnmf from '../../index' declare module '../../index' { /** One. UDP Socket Example,Default use IPv4 Agreement。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.html */ interface UDPSocket { /** Bind a system of randomly assigned available ports,Or bind a specified port number * @supported weapp * @example * ```tsx * const udp = Vnmf.createUDPSocket() * udp.close() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.bind.html */ bind( /** Specify port number to bind,Returns available ports that are randomly distributed by the system without sending them back */ port: number, ): number /** Settings IP_TTL Socket Options,For setting one IP Maximum number of jumps allowed for package transfer * @supported weapp * @example * ```tsx * const udp = Vnmf.createUDPSocket() * udp.onListening(function () { * udp.setTTL(64) * }) * udp.bind() * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.setTTL.html */ setTTL( /** ttl The parameters can be: 0 Present. 255 Between */ ttl: number ): void /** To Specified IP and port Can not open message * @supported weapp * @example * ```tsx * const udp = Vnmf.createUDPSocket() * udp.bind() * udp.send({ * address: '192.168.193.2', * port: 8848, * message: 'hello, how are you' * }) * ``` * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.send.html */ send(option: UDPSocket.send.Option): void /** Preconnect to the specified IP and port,We need to work together. write We'll use the method together. * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.connect.html */ connect(option: UDPSocket.connect.Option): void /** Usage with send Same method.,If no advance call is made connect and send No difference(Watch out, even if it's called. connect Also need to fill address and port parameters in this interface) * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.write.html */ write(): void /** Close UDP Socket Example,Equivalent to destruction。 After closing,UDP Socket Instances can't send messages,Every call `UDPSocket.send` The error will be triggered.,And... message The event echo function will never be performed again.。Yes. `UDPSocket` Example to be created by Native Force Quote,Make sure they don't. GC。Yes. `UDPSocket.close` Then we'll remove the strong references to it.,Jean. UDPSocket Instance Compliance GC。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.close.html */ close(): void /** Listen to shut-down events * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onClose.html */ onClose( /** Close event echo function */ callback: UDPSocket.onClose.Callback, ): void /** Disable listening shut-downs * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offClose.html */ offClose( /** Close event echo function */ callback: UDPSocket.onClose.Callback, ): void /** Listening Errors * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onError.html */ onError( /** The echo function for error events */ callback: UDPSocket.onError.Callback, ): void /** Disable bug listening * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offError.html */ offError( /** The echo function for error events */ callback: UDPSocket.onError.Callback, ): void /** Listening to events that start listening packet messages * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onListening.html */ onListening( /** Listening to events that start listening packet messages */ callback: UDPSocket.onListening.Callback, ): void /** Disable listening to events that start packet messages * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offListening.html */ offListening( /** Listening to events that start listening packet messages */ callback: UDPSocket.onListening.Callback, ): void /** I'm listening to the news. * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.onMessage.html */ onMessage( /** The echo function for the event which message was received */ callback: UDPSocket.onMessage.Callback, ): void /** Cancel listening to incoming messages. * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/UDPSocket.offMessage.html */ offMessage( /** The echo function for the event which message was received */ callback: UDPSocket.onMessage.Callback, ): void } namespace UDPSocket { namespace connect { interface Option { /** Cannot initialise Evolution's mail component. */ address: string /** Port number to send messages */ port: number } } namespace onClose { /** ♪ When one socket Respond function for the event when is completely closed */ type Callback = (...args: unknown[]) => void } namespace onError { /** The echo function for error events */ type Callback = (result: CallbackResult) => void interface CallbackResult extends VnmfGeneral.CallbackResult { /** Cannot initialise Evolution's mail component. */ errMsg: string } } namespace onListening { /** Listening to events that start listening packet messages */ type Callback = (...args: unknown[]) => void } namespace onMessage { /** The echo function for the event which message was received */ type Callback = (result: CallbackResult) => void interface CallbackResult extends VnmfGeneral.CallbackResult { /** I've got a message. */ message: ArrayBuffer /** Cannot initialise Evolution's mail component. */ remoteInfo: RemoteInfo /** Receiver Address Information */ localInfo: LocalInfo } /** Cannot initialise Evolution's mail component. */ interface RemoteInfo { /** Cannot initialise Evolution's mail component. socket Address */ address: string /** The protocol group to be used,Yes. IPv4 Or... IPv6 */ family: string /** Port number */ port: number } /** Receiver Address Information */ interface LocalInfo { /** He's the one who received message. socket Address */ address: string /** The protocol group to be used,Yes. IPv4 Or... IPv6 */ family: string /** Port number */ port: number /** message Size,Units:Bytes */ size: number } } namespace send { interface Option { /** Cannot initialise Evolution's mail component.。It's in the base. <= 2.9.3 The version must be on the same page as this one. IP Address,or a domain name address in secure list;The later version can be arbitrary. IP and domain names */ address: string /** Port number to send messages */ port: number /** Data to send */ message: string | ArrayBuffer /** Offset to send data,Only if... message Yes. ArrayBuffer Valid for type * @default 0 */ offset?: number /** Length of data sent,Only if... message Yes. ArrayBuffer Valid for type * @default message.byteLength */ length?: number } } } interface VnmfStatic { /** Create UDP Socket Example。Read carefully before using[Relevant notes](https://developers.weixin.qq.com/miniprogram/dev/framework/ability/network.html)。 * @supported weapp * @see https://developers.weixin.qq.com/miniprogram/dev/api/network/udp/wx.createUDPSocket.html */ createUDPSocket(): UDPSocket } }