Event
The Event module in ZDK manages live, single-session events such as webinars, AMAs, workshops, and concerts. It tracks user lifecycle events (join/leave) and provides a built-in chat channel for real-time interaction. Participants can post messages, ask questions, and receive announcements directly within the session interface.
The module also exposes a DASH-compliant livestream URL, which can be integrated with any compatible media player (e.g., ShakaPlayer, dash.js, video.js). This design enables developers to embed both live video and chat seamlessly, offering a self-contained solution for interactive, time-boxed sessions.
Dependencies- core
- user
- websocket
Initialization
const event = new createEvent({
webSocketModule: webSocket,
userModule: user,
config: {
host: 'event.dev.zu.casa'
}
});Actions
joinEvent
Action type(token: string) => Promise<void>
It gives the client the possibility to join to selected event and connect to media server.
Parameterstoken- a short-lived, server-issued token created on request that encodes the user’s permissions for the specific event they’re joining.
Returns a promise that resolves once the user entered the event.
Possible errorsActionCallError- Can not perform this action (joinEvent) while module is not connected with WebSocket.ActionCallError- You’ve already joined a event- other error types may occur, the list will be expanded during development
leaveEvent
Action type() => void
Removes user from the event. It automatically clears the state of the event and sets eventModule
status to disconnected.
ActionCallError- Can not perform this action (leaveEvent) while module is not connected with WebSocketActionCallError- Invalid token.ActionCallError- Expired token.ActionCallError- Can not perform this action (leaveEvent) because you are not in any event.- other error types may occur, the list will be expanded during development
kickMember
Action type(userId: string, reason?: string) => Promise<void>
Description Kicks the targeted user from the current event.
ParametersuserId- id of the targeted userreason- cause for removing someone from an event
Returns a promise that resolves when request is successfully sent.
Possible errorsActionCallError- Can not perform this action (kickMember) while module is not connected with WebSocket.ActionCallError- Can not perform this action (kickMember) because you did not join any event.ActionCallError- Can not perform this action (kickMember) on yourself.- other error types may occur, the list will be expanded during development
blockMember
Action type(userId: string, duration: bigint, reason?: string) => Promise<void>
Description Blocks the targeted user, establishing a restriction that prevents the user from entering the current event, and if the user is currently in the event, they will be kicked out immediately. Parameters
userId- id of the targeted userduration- time in minutes the block remains active; 0 implies a permanent blockreason- cause for blocking user
Returns a promise that resolves when request is successfully sent.
Possible errorsActionCallError- Can not perform this action (blockMember) while module is not connected with WebSocket.ActionCallError- Can not perform this action (blockMember) because you did not join any event.ActionCallError- Can not perform this action (blockMember) on yourself.- other error types may occur, the list will be expanded during development
unblockMember
Action type(userId: string) => Promise<void>
Description Removes the block on the targeted user, allowing entry to the event again. If the user was removed, they can now rejoin. Parameters
userId- id of the targeted user
Returns a promise that resolves when request is successfully sent.
Possible errorsActionCallError- Can not perform this action (unblockMember) while module is not connected with WebSocket.ActionCallError- Can not perform this action (unblockMember) because you did not join any event.ActionCallError- Can not perform this action (unblockMember) on yourself.ActionCallError- Can not perform this action (unblockMember) on member which is not blocked.- other error types may occur, the list will be expanded during development
generateLivestreamUrl
Action type() => Promise<string>
It gives the client the possibility to generate DASH-compliant livestream URL.
Return valueReturns a promise that resolves with livestream URL.
Possible errorsActionCallError- Can not perform this action (joinEvent) while module is not connected with WebSocket.ActionCallError- Can not perform this action (joinEvent) while user is not connected to an event.ActionCallError- Can not perform this action (joinEvent) while event is not started yet.- other error types may occur, the list will be expanded during development
Data (Getters)
status
Getter output type:
'disconnected' | 'connecting' | 'connected' | 'reloading'
disconnected- not connected to any eventconnecting- trying to connect to selected eventconnected- connected and data about the event is available - ready to display event UIreloading- because of connection lost, the event state can be temporarily desynchronized, this state appear after we are trying to synchronize all the data again. You can still show the user the whole event UI based on old data, but you can inform them that we are ‘reloading’ it and soon user will be fully connected.
eventStatus
Getter output type:
'unavailable' | 'pending' | 'started' | 'finished' | 'canceled'
unavailable- not connected to any eventpending- created but not started eventstarted- event is currently livefinished- event completed successfullycanceled- event aborted before completion
chatId
Getter output type:
string | undefined
Gives access to chatId associated with the event.
If the client did not enter any event, undefined will be returned.
eventId
Getter output type:
string | undefined
Gives access to eventId of the current event.
If the client did not enter any event, undefined will be returned.
membersAmount
Getter output type:
number
Gives access to a number that represents the amount of users in the event.
If the client did not enter any event, 0 will be returned.
isEventSyncing
Getter output type:
boolean
This value give you information if some of the data are incorrect in the state, and we are fixing it.
The state might be inaccurate at the moment. It happens after connecting
or reloading. When fetching event state will be interrupted by a websocket packet.
If it is true you can show in UI a status that says that state is syncing or do nothing.
If the client did not enter any event, false will be returned.
Events
The module provides the following ListenerCreator:
onUserKicked
ListenerCreator output type{ userId: string, eventId: string, reason: string}
The method sets up a function that will be called whenever any user from the event (including you) is kicked from the event.