你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn

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