Compartilhar via


EventHandlerImpl<T> Class

  • java.lang.Object
    • com.microsoft.cognitiveservices.speech.util.EventHandlerImpl<T>

Type Parameters

T

public class EventHandlerImpl

Implements the binding between the Speech SDK core event handler and Java event handling.

Constructor Summary

Constructor Description
EventHandlerImpl(AtomicInteger runCounter)

Creates and initializes a new instance of the EventHandlerImpl.

Method Summary

Modifier and Type Method and Description
void addEventListener(EventHandler<T> handler)

Registers a new event handler with the associated event.

void fireEvent(Object sender, T e)

Fires an event by calling sequentially all registered handlers.

boolean isUpdateNotificationOnConnectedFired()

Checks if a client has subscribed to events.

void removeEventListener(EventHandler<T> handler)

Unregisters the event handler from the associated event.

void updateNotificationOnConnected(Runnable notifyConnectedOnce)

Updates the handler to be notified when the first client subscribes to the event.

Methods inherited from java.lang.Object

java.lang.Object.clone java.lang.Object.equals java.lang.Object.finalize java.lang.Object.getClass java.lang.Object.hashCode java.lang.Object.notify java.lang.Object.notifyAll java.lang.Object.toString java.lang.Object.wait java.lang.Object.wait java.lang.Object.wait

Constructor Details

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 Details

addEventListener

public void addEventListener(EventHandler handler)

Registers a new event handler with the associated event.

Parameters:

handler - The handler.

fireEvent

public void fireEvent(Object sender, T e)

Fires an event by calling sequentially all registered handlers.

Parameters:

sender - The origin of the event.
e - The event.

isUpdateNotificationOnConnectedFired

public boolean isUpdateNotificationOnConnectedFired()

Checks if a client has subscribed to events.

Returns:

True if a client has subscribed to events, false otherwise.

removeEventListener

public void removeEventListener(EventHandler handler)

Unregisters the event handler from the associated event.

Parameters:

handler - The handler.

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.

Applies to