networkStatusChanged
Function Introduction
Description
Called when the client's network status changes.
- uni-app
- Browser/Electron/MiniProgram
- React-Native
- Unity
Function Prototype
IMSDK.networkStatusChanged(operationID?: string): Promise<WsResponse>
Input Parameters
None
Return Results
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<WsResponse> | Successful callback |
Promise.catch() | Promise<WsResponse> | Failure callback |
Code Example
import { getSDK } from 'open-im-sdk-wasm';
const IMSDK = getSDK();
// use in electron with ffi
// import { getWithRenderProcess } from '@openim/electron-client-sdk/lib/render';
// const { instance: IMSDK } = getWithRenderProcess();
// use in mini program
// import { OpenIMSDK } from 'open-im-sdk';
// const IMSDK = new OpenIMSDK();
IMSDK.networkStatusChanged()
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
IMSDK.asyncApi('networkStatusChanged', operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Required | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, for problem tracking. It is recommended to use the current time and a random number |
Return Results
The function is Promise-ified using the
openim-uniapp-polyfill
package. When calling, usethen
andcatch
to judge and handle success and failure callbacks.
Parameter Name | Parameter Type | Description |
---|---|---|
Promise.then() | Promise<void> | Successful callback |
Promise.catch() | Promise<CatchResponse> | Failure callback |
Code Example
import IMSDK from 'openim-uniapp-polyfill';
IMSDK.asyncApi('networkStatusChanged', IMSDK.uuid())
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
OpenIMSDKRN.networkStatusChange(operationID: string): Promise<void>
Input Parameters
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
operationID | string | Yes | Operation ID, used for problem location, keep unique, suggest using current time and random number |
Return Result
Code Example
import OpenIMSDKRN from "open-im-sdk-rn";
OpenIMSDKRN.networkStatusChange('operationID')
.then(() => {
// Successful call
})
.catch(({ errCode, errMsg }) => {
// Failed call
});
Function Prototype
public static void NetworkStatusChanged(OnSucOrError cb)
Input Parameter
Parameter Name | Parameter Type | Mandatory | Description |
---|---|---|---|
cb | OnSucOrError | Yes | Callback |
Return Result
Code Example
IMSDK.NetworkStatusChanged((suc,errCode,errMsg)=>{
});