Class EventHandlerImpl<T>
- java.lang.Object
-
- com.microsoft.cognitiveservices.speech.util.EventHandlerImpl<T>
-
public class EventHandlerImpl<T> extends Object
Implements the binding between the Speech SDK core event handler and Java event handling.
-
-
Constructor Summary
Constructors Constructor Description EventHandlerImpl(AtomicInteger runCounter)Creates and initializes a new instance of the EventHandlerImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventListener(EventHandler<T> handler)Registers a new event handler with the associated event.voidfireEvent(Object sender, T e)Fires an event by calling sequentially all registered handlers.booleanisUpdateNotificationOnConnectedFired()Checks if a client has subscribed to events.voidremoveEventListener(EventHandler<T> handler)Unregisters the event handler from the associated event.voidupdateNotificationOnConnected(Runnable notifyConnectedOnce)Updates the handler to be notified when the first client subscribes to the event.
-
-
-
Constructor Detail
-
EventHandlerImpl
public EventHandlerImpl(AtomicInteger runCounter)
Creates and initializes a new instance of the EventHandlerImpl.- Parameters:
runCounter- Counter to track if an event is in progress or not.
-
-
Method Detail
-
updateNotificationOnConnected
public void updateNotificationOnConnected(Runnable notifyConnectedOnce)
Updates the handler to be notified when the first client subscribes to the event.- Parameters:
notifyConnectedOnce- The handler to be called when the first client subscribes to the event. If there is already a client subscribed, the callback is immediately invoked.
-
isUpdateNotificationOnConnectedFired
public boolean isUpdateNotificationOnConnectedFired()
Checks if a client has subscribed to events.- Returns:
- True if a client has subscribed to events, false otherwise.
-
addEventListener
public void addEventListener(EventHandler<T> handler)
Registers a new event handler with the associated event.- Parameters:
handler- The handler.
-
removeEventListener
public void removeEventListener(EventHandler<T> handler)
Unregisters the event handler from the associated event.- Parameters:
handler- The handler.
-
-