How events are emitted and consumed.
EventsManager
class and several Event
subclasses representing various event types.
EventsManager
class is responsible for managing the event queue and handling events asynchronously. The class provides methods for publishing events, starting the event loop, handling events, and ending the event loop.
EventsManager
constructor accepts an optional list of EventType
subscriptions. By default, it initializes an empty set of subscriptions, an asynchronous queue, and sets the active
attribute to False
.
publish_event
method takes an Event
object as input and adds it to the queue if its type is in the set of subscribed event types.
TRANSCRIPT
: Indicates a partial transcript for the conversation has been received.TRANSCRIPT_COMPLETE
: Indicates the transcript is complete (ie conversation has ended).PHONE_CALL_CONNECTED
: Indicates a phone call has been connected.PHONE_CALL_ENDED
: Indicates a phone call has ended.RECORDING
: (Vonage Only) Indicates a secure URL containing a recording of the call is available. Requires recording=true
in VonageConfig
.EventsManager
class can be used to consume the TRANSCRIPT_COMPLETE
event and save the transcript to a file using the add_transcript
method:
EventsManager
subclass is created with a subscription to the TRANSCRIPT_COMPLETE
event. The handle_event
method is overridden to save the transcript to a file using the add_transcript
method when the TRANSCRIPT_COMPLETE
event is received.