Skip to main content

Disconnect

Disconnect

The disconnect method is used to terminate the IM connection.

Use cases: Recommended when logging out accounts or switching between accounts.

Interface

RongIMLib.disconnect()

Parameters

None

Sample Code

RongIMLib.disconnect().then(() => {
console.log('Disconnected successfully')
})

Deinitialize

The destroy method automatically calls disconnect to terminate the current connection, clears all listeners and timers, and stops log reporting services.

Use cases:

  1. When exiting the application, it's recommended to call this method to release resources
  2. When changing App Keys, you must first call this method to destroy the current instance before performing initialization with the new App Key

Interface

RongIMLib.destroy()

Parameters

None

Sample Code

RongIMLib.destroy().then(() => {
console.log('Deinitialization completed')
})