Skip to main content

Work in progress

PrivMX Endpoint Java is not up to date with the core documentation. Some of the features you've seen described in other parts of the documentation might not be mentioned here. Those changes do not influence compatibility, however

Overview

Events enable your application to react dynamically to changes within user context.

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

  1. Start the event loop:
container.startListening()
  1. Add event listener for 'ThreadCreatedEvent' related with callbackID
val callbackID = "CALLBACK_ID"
container.privmxEndpoint.registerCallback(
callbackID,
EventType.ThreadCreatedEvent
){ newThreadData ->
// some actions with newThreadData
}
  1. Remove the event listener when no longer needed:
connection.unregisterCallbacks(callbackID)

Unregister callbacks

Unregister all callbacks identified by callbacksID:

val callbacksID = "CALLBACKS_ID"
connection.unregisterCallbacks(callbacksID)