Version 2.2.0
Overview
Events enable your application to react dynamically to changes within user context.
Info
Before working with Events, follow our Getting Started Guide. It will show you how to set up your project to work with PrivMX Bridge.
The sample code on this page is based on the initial assumptions.
These events are triggered automatically when a relevant change occurs. You can subscribe to them by registering event listeners. This allows you to respond to changes as they happen in real-time.
Caveats
- All callback are related to the connection on which they were registered.
- Calling
PrivmxEndpointContainer.stopListening()
does not delete event listeners. - Disconnecting deletes all event listeners related to the connection.
Quick start
- Start the event loop:
endpointContainer.startListening()
- Add event listener for 'ThreadCreatedEvent' related with
callbackID
val callbackID = "CALLBACK_ID"
endpointSession.registerCallback(
callbackID,
EventType.ThreadCreatedEvent
){ newThreadData ->
// some actions with newThreadData
}
- Remove the event listener when no longer needed:
endpointSession.unregisterCallbacks(callbackID)
Unregister callbacks
Unregister all callbacks identified by callbacksID
:
val callbacksID = "CALLBACKS_ID"
endpointSession.unregisterCallbacks(callbacksID)