- Event Handling: The callback function is invoked when its associated Event takes place. This enables you to execute specific logic in response to changes or actions within the Room.
- Single Listener Binding: When attaching a callback function via the
on()method, remember that only one listener can be attached per event type. If a new callback is registered for the same event, it will replace the previous listener. - Function Parameters: Depending on the event type, the callback function may receive parameters that provide context or data related to the event. Tailor your callback to handle this data appropriately.
- Integration with Room: Utilizing the callback function allows you to seamlessly integrate interactive features within the VmonsterRoom instance, enhancing the responsiveness of your application to User and AI Avatar actions.
on()
Theon() method is used to attach an event listener to a Event.
| event | callback function type |
|---|---|
joined | () ⇒ void |
joining | () ⇒ void |
left | () ⇒ void |
aiavatar-start-speaking | () ⇒ void |
aiavatar-message | (message: string) ⇒ void |
aiavatar-stop-speaking | () ⇒ void |
stt-data | (sttData: STTData) ⇒ void |
stt-error | (error: any) ⇒ void |