Methods and Events
Events

Events

List of all the methods and events available in the Samvyo SDK Instance, along with explanations and code examples for implementation.

micStart

Emitted when a new audio channel is created, indicating that a remote peer has started sending audio.

Parameters:

  • peerId: The ID of the peer sending audio.
  • audioTrack: The audio track being sent.
  • type: Indicates whether the audio is from a local or remote source.

Example:

samvyoInstance.on("micStart", ({ peerId, audioTrack, type }) => {
  console.log(`Audio started from peer: ${peerId}`);
  // Handle the incoming audio track
});

micEnd

Emitted when a remote audio channel is closed, indicating that the audio stream has ended.

Parameters:

  • peerId: The ID of the peer whose audio has ended.

Example:

samvyoInstance.on("micEnd", ({ peerId }) => {
  console.log(`Audio ended from peer: ${peerId}`);
  // Update UI or internal state
});

videoStart

Emitted when a new video channel is created, indicating that a remote peer has started sending video.

Parameters:

  • peerId: The ID of the peer sending video.
  • videoTrack: The video track being sent.
  • type: Indicates the source of the video.

Example:

samvyoInstance.on("videoStart", (data) => {
  console.log(`Video started from peer: ${data.peerId}`);
  // Display the incoming video track
});

videoEnd

Emitted when a remote video channel is closed, indicating that the video stream has ended.

Parameters:

  • peerId: The ID of the peer whose video has ended.
  • type: Indicates the source of the video.

Example:

samvyoInstance.on("videoEnd", ({ peerId, type }) => {
  console.log(`Video ended from peer: ${peerId}`);
  // Update UI or internal state
});

newPeer

Emitted when a new peer joins the room, providing details about the peer.

Parameters:

  • peerId: The ID of the new peer.
  • peerName: The name of the new peer.
  • type: The type of peer (e.g., local or remote).
  • peerRole: The role of the peer (e.g., moderator, participant, viewer, attendee).
  • enableChatOption: Boolean indicating if chat is enabled for the room.
  • enableScreenSharing: Boolean indicating if screen sharing is enabled for the room.
  • participantType: The participant type (e.g., moderator, participant, presenter, viewer, attendee).
  • userSettings: Object containing user-specific permissions (e.g., allowPresenterRaiseHand, allowPresenterPublicChat, allowPresenterPrivateChat, allowRaiseHand, allowPublicChat, allowPrivateChat).
  • stageModeSettings: Object containing stage mode settings (optional).

Example:

samvyoInstance.on("newPeer", (data) => {
  console.log(`New peer joined: ${data.peerId}, Role: ${data.peerRole}`);
  // Update UI to reflect new peer
  if (data.type === "local") {
    // Handle local peer initialization
    console.log("Chat enabled:", data.enableChatOption);
    console.log("Screen sharing enabled:", data.enableScreenSharing);
  }
});

peerLeft

Emitted when a peer leaves the room, allowing the application to handle peer disconnections.

Parameters:

  • peerId: The ID of the new peer.

Example:

samvyoInstance.on("peerLeft", (data) => {
  console.log(`Peer left: ${data.peerId}`);
  // Update UI to remove the peer
});

activeSpeaker

Emitted when a peer is detected as the active speaker, which can be used for UI updates.

Parameters:

  • peerId: The ID of the active speaker

Variables

  • These values are also available in the currentlyActiveSpeaker variable. It contains the peerId and the volume of currently active speaker. The value changes whenever the currently active speaker changes.
const currentlyActiveSpeaker = samvyoInstance.currentlyActiveSpeaker;

Example:

samvyoInstance.on("activeSpeaker", ({ peerId }) => {
  console.log(`Active Speaker: ${peerId}`);
  // Update UI to highlight speaker
});

consumerAdmissionDenied

Emitted in manual subscription mode when the server denies creating or resuming a consumer for a given peer/track.
This usually happens when room limits are reached (for example, maximum number of allowed active consumers) or when a specific subscription request cannot be fulfilled.

Parameters:

  • data: Object containing the raw server payload for the denied subscription.
    This typically includes information such as the peer, track/media tag, and a reason field explaining why admission was denied.

Example:

samvyoInstance.on("consumerAdmissionDenied", (data) => {
  console.warn("Subscription was denied:", data);
 
  // You can inspect data to understand what failed and why,
  // and update your UI (e.g., show a toast, fall back to audio-only, etc.)
});

consumerPreempted

Emitted in manual subscription mode when an existing consumer is preempted by the server, typically because a per‑peer or global consumer limit has been reached and another subscription has taken priority.

Parameters:

  • consumerId: ID of the consumer that was closed.
  • senderPeerId: ID of the remote peer whose track was being consumed.
  • mediaTag: Track tag (for example "cam-video", "cam-audio", "screen-video", "screen-audio").
  • reason: String reason from the server (for example "preempted").
  • preemptedBy (optional): Information about the subscription/peer that caused the preemption (if provided by the server).
  • source (optional): Additional source metadata from the server message.

Example:

samvyoInstance.on("consumerPreempted", (info) => {
  console.warn(
    "Consumer preempted:",
    info.consumerId,
    "from peer",
    info.senderPeerId,
    "tag",
    info.mediaTag,
    "reason",
    info.reason
  );
 
  // Typical handling:
  // - Update UI to remove that video tile
  // - Optionally re-request subscription for a different peer
  // - Show a message explaining max-consumer limits were hit
});

existingTracks

Emitted in manual subscription mode when the server sends a full snapshot of currently available remote tracks.

Parameters:

  • tracks: Array of track metadata objects. Each entry typically includes:
    • senderPeerId / peerId: ID of the peer publishing the track.
    • mediaTag: Track tag (e.g., "cam-audio", "cam-video", "screen-video", "screen-audio").
    • Other implementation‑specific fields (codec, paused state, etc.).

Example:

samvyoInstance.on("existingTracks", ({ tracks }) => {
  console.log("Existing remote tracks:", tracks);
  // Use this to build a manual-subscription UI or debug what is available
});

trackAvailable

Emitted in manual subscription mode when a new remote track becomes available from a peer.

Parameters:

  • senderPeerId / peerId: The ID of the peer publishing the track.
  • mediaTag: Tag identifying the track type (for example "cam-video" or "screen-audio").
  • Other implementation‑specific fields from the server message.

Example:

samvyoInstance.on("trackAvailable", (trackInfo) => {
  console.log("Track available:", trackInfo.mediaTag, "from", trackInfo.senderPeerId || trackInfo.peerId);
  // Decide whether to subscribe/stage based on your layout logic
});

trackUnavailable

Emitted in manual subscription mode when a previously available track is no longer available (for example, peer stopped a cam/screen track).

Parameters:

  • senderPeerId / peerId: The ID of the peer.
  • mediaTag: Tag of the track that became unavailable.

Example:

samvyoInstance.on("trackUnavailable", (trackInfo) => {
  console.log("Track unavailable:", trackInfo.mediaTag, "from", trackInfo.senderPeerId || trackInfo.peerId);
  // Clean up any UI elements or consumers tied to this track
});

effectiveSubscriptionSnapshot

Emitted when emitEffectiveSubscriptionSnapshot() is called in manual subscription mode, providing a full snapshot of desired vs. effective subscriptions.

Parameters:

  • ts: Timestamp when the snapshot was computed.
  • manualSubscription: Boolean indicating if manual subscription mode is enabled.
  • roomId: Current room ID.
  • selfPeerId: Local peer ID.
  • desired: Object with:
    • peers: All peers you’ve marked as subscribed or staged.
    • activePeers: Peers marked as actively subscribed.
    • stagedPeers: Peers marked as staged.
  • effective: Object with:
    • peers: Map keyed by peerId, each containing:
      • mode: "subscribed" | "staged" | "none".
      • tracks: Per‑track info with mediaTag, active, staged, etc.
    • activePeers: Peers with at least one active track.
    • stagedPeers: Peers with only staged tracks.
    • nonePeers: Peers that are desired but currently have no active/staged consumers.
  • history (present when called with includeHistory: true):
    • admissionDenied: Array of past consumerAdmissionDenied messages.
    • preemptions: Array of preemption events.
    • lastResponses: Last subscribePeers, stagePeers, and unsubscribePeers responses.

Example:

samvyoInstance.on("effectiveSubscriptionSnapshot", (snapshot) => {
  console.log("Manual-subscription snapshot:", snapshot);
  // Useful for debugging large-room layouts and subscription decisions
});

peerMuted / peerUnMuted

Emitted when a peer mutes or unmutes their audio, allowing for updates to the UI or internal state.

Parameters:

  • peerId: The ID of the peer who muted/unmuted.
  • type: The type of peer (e.g., local or remote).

Example:

samvyoInstance.on("peerMuted", ({ peerId, type }) => {
  console.log(`Peer muted: ${peerId}`);
  // Update UI to reflect muted state
});
samvyoInstance.on("peerUnMuted", ({ peerId, type }) => {
  console.log(`Peer unmuted: ${peerId}`);
  // Update UI to reflect unmuted state
});

speakingWhileMuted

Emitted when a peer is detected speaking while their microphone is muted.

Parameters:

  • peerId: The ID of the peer who is speaking while muted.
  • audioLevel: The audio level detected (in dB).
  • timestamp: Timestamp when the event occurred.
  • message: Message describing the event.

Example:

samvyoInstance.on("speakingWhileMuted", ({ peerId, audioLevel, timestamp, message }) => {
  console.log(`Peer ${peerId} is speaking while muted. Audio level: ${audioLevel}dB`);
  // Show notification or update UI
});

deviceListUpdated

Emitted when a new audioInput or videoInput device is detected. deviceList variable will be updated with all the avaliable devices

Example:

samvyoInstance.on("deviceListUpdated", () => {
  console.log(`New device detected`);
  // Update UI to let user know that a new device is detected
  const updatedDeviceList = samvyoInstance.deviceList;
});

updatedDeviceList will look similar to this

{ videoInputs:[{deviceId:"1234556assafdfrgregsrdfsfa", label:"logitech c320"},{deviceId:"1234556assafdfrbhbhgtdrtdghffsfa", label:"dell super hd a100"}],
	audioInputs:[{deviceId:"12qwertyueafdfrgregsrdfsfa", label:"logitech c320 mic"},{deviceId:"12345kjbdjsgygtusdbhbhgtdrtdghffsfa", label:"dell super hd a100 mic"}]}

ssVideoStart

Emitted when a screenshare is started by a peer.

Parameters:

  • peerId: The ID of the peer who started screen share.
  • videoTrack: Screen share video track.
  • type: The type of peer (e.g., local or remote).

Example:

samvyoInstance.on("ssVideoStart", ({ peerId, videoTrack, type }) => {
  console.log(`Screen share started by peer: ${peerId}`);
  // Update UI to display the screen to other users using videoTrack
});

ssVideoStop

Emitted when a screenshare is stopped by a peer.

Parameters:

  • peerId: The ID of the peer who stopped the screen share.

Example:

samvyoInstance.on("ssVideoStop", ({ peerId }) => {
  console.log(`Screen share stopped by peer: ${peerId}`);
  // Update UI accordingly
});

ssAudioStart

Emitted when audio is shared along with screen share.

Parameters:

  • peerId: The ID of the peer who shared the audio along with screen share.
  • audioTrack: Audio track that is played during screen share
  • type: The type of peer(e.g., local or remote).

Example:

samvyoInstance.on("ssAudioStart", (data) => {
  console.log(`Audio and screen share started by peer: ${data.peerId}`);
  // Add new audio track
});

ssAudioStop

Emitted when audio is stoped during screen share.

Parameters:

  • peerId: The ID of the peer who stoped sharing the audio during screen share.
  • audioTrack: null
  • type: The type of peer(e.g., local or remote).

Example:

samvyoInstance.on("ssAudioStop", (data) => {
  console.log(`Audio stoped during screen share by peer: ${data.peerId}`);
  // Remove audio track that is being played
});

initSuccess

Emitted when the SDK has been successfully initialized.

Example:

samvyoInstance.on("initSuccess", async () => {
  console.log("SDK initialized successfully");
  // Proceed with joining the room
});

initError

Emitted when an error occurs during SDK initialization.

Parameters:

  • error: The error object or message.

Example:

samvyoInstance.on("initError", (error) => {
  console.error("Error initializing SDK:", error);
  // Handle initialization error
});
 
### connectionStateChange
 
Emitted whenever the SDK's connection state to the signaling/media server changes.
 
**Parameters:**
 
- `status`: One of:
  - `"connected"` – initial successful connection.
  - `"reconnected"` – connection was lost and then restored.
  - `"disconnected"` – WebSocket was closed.
  - `"media-restored"` – send/recv transports are both back to `"connected"` after a transient issue.
- `code` (optional): WebSocket close code when `status === "disconnected"`.
- `reason` (optional): Human‑readable reason string for disconnection.
 
**Example:**
 
```javascript
samvyoInstance.on("connectionStateChange", ({ status, code, reason }) => {
  console.log("Connection state:", status, code, reason);
  if (status === "disconnected") {
    // Show reconnecting UI, disable controls, etc.
  }
  if (status === "media-restored") {
    // Hide reconnect banner, restore full UI
  }
});

joinSuccess

Emitted when a peer successfully joins the room.

Parameters:

  • data: Optional data object (may be empty).

Example:

samvyoInstance.on("joinSuccess", (data = {}) => {
  console.log("Successfully joined room", data);
  // Update UI to show joined state
});

joinError

Emitted when an error occurs while joining the room.

Parameters:

  • error: The error object or message.

Example:

samvyoInstance.on("joinError", (error) => {
  console.error("Error joining room:", error);
  // Handle join error
});
 
### error
 
Generic SDK‑level error event (primarily for P2P flows).
 
**Parameters:**
 
- `type`: A short error type string (for example, `"mediaError"` or `"joinError"`).
- `message`: Human‑readable error message.
 
**Example:**
 
```javascript
samvyoInstance.on("error", ({ type, message }) => {
  console.error(`[SDK error] ${type}: ${message}`);
  // Show toast / alert, or guide the user to fix (e.g., enable mic/camera)
});

updateCId

Emitted when the connection ID (CId) is updated for a peer.

Parameters:

  • message: Optional message string.
  • cId: The connection ID.
  • peerId: The ID of the peer whose CId was updated.
  • isMyCId: Boolean indicating if this is the local peer's CId.

Example:

samvyoInstance.on("updateCId", ({ message, cId, peerId, isMyCId }) => {
  console.log(`CId updated: ${cId} for peer ${peerId}`);
  // Store or use the connection ID
});

recordingStarted

Emitted when recording is started in a room.

Parameters:

  • None (parameters may vary by implementation).

Example:

samvyoInstance.on("recordingStarted", () => {
  console.log("Recording has been started in this room");
  // Update UI to show recording indicator
});

recordingEnded

Emitted when recording is ended.

Parameters:

  • None

Example:

samvyoInstance.on("recordingEnded", ({}) => {
  console.log(`Recording has been ended in this room`);
  // Remove audio track that is being played
});

liveStreamingStarted

Emitted when a live stream to an external RTMP endpoint has started.

Parameters:

  • startTime: The timestamp when streaming started.

Example:

samvyoInstance.on("liveStreamingStarted", ({ startTime }) => {
  console.log(`Live streaming started at ${startTime}`);
});

liveStreamingEnded

Emitted when the live stream is stopped.

Parameters:

  • None (parameters may vary by implementation).

Example:

samvyoInstance.on("liveStreamingEnded", () => {
  console.log("Live streaming ended");
  // Update UI to reflect streaming stopped
});

peerConnected

Emitted when a P2P direct connection is established with a peer (P2P rooms only).

Parameters:

  • peerId: The ID of the peer with whom the connection was established.

Example:

samvyoInstance.on("peerConnected", ({ peerId }) => {
  console.log("P2P direct connection established with peer:", peerId);
  // Show connection indicator
});

peerDisconnected

Emitted when a P2P connection is lost with a peer (P2P rooms only).

Parameters:

  • peerId: The ID of the peer with whom the connection was lost.

Example:

samvyoInstance.on("peerDisconnected", ({ peerId }) => {
  console.warn("P2P connection lost with peer:", peerId);
  // Show reconnection message
});

customMessageError

Emitted when an error occurs while sending or receiving a custom message.

Parameters:

  • error: The error object containing error details.

Example:

samvyoInstance.on("customMessageError", (error) => {
  console.error("Custom message error:", error);
  // Handle custom message error
});

transcriptionStarted

Emitted when the transcription service has successfully started.

Example:

samvyoInstance.on("transcriptionStarted", () => {
  console.log("Transcription service started");
});

transcriptionStopped

Emitted when the transcription service has stopped.

Example:

samvyoInstance.on("transcriptionStopped", () => {
  console.log("Transcription service stopped");
});

transcription

Emitted when a transcription result is received (e.g., from Deepgram).

Parameters:

  • transcript: The transcribed text.
  • isFinal: Boolean indicating if the result is final or interim.
  • peerId: The ID of the speaker.

Example:

samvyoInstance.on("transcription", (data) => {
  console.log(`Transcription [${data.isFinal ? 'Final' : 'Interim'}]: ${data.transcript}`);
});

transcriptionError

Emitted when an error occurs with the transcription service.

Parameters:

  • error: The error message string.

Example:

samvyoInstance.on("transcriptionError", ({ error }) => {
  console.error("Transcription error:", error);
});

moderatorAuthentication

Emitted when a moderator authentication request is received.

Parameters:

  • moderatorName: Name of the moderator
  • requesterName: Name of the user requesting authentication
  • requesterPeerId: Peer ID of the user requesting authentication
  • text: Additional text message for the authentication request

Example:

samvyoInstance.on("moderatorAuthentication", (data) => {
  console.log(`Authentication request from ${data.requesterName} to ${data.moderatorName}`);
  // Handle moderator authentication request
});

authenticationRequested

Emitted when an authentication request is made.

Parameters:

  • requesterName: Name of the user requesting authentication
  • requesterId: ID of the user requesting authentication
  • text: Additional text message for the authentication request

Example:

samvyoInstance.on("authenticationRequested", (data) => {
  console.log(`Authentication requested by ${data.requesterName}`);
  // Handle authentication request
});

moderatorAuthStatus

Emitted when a moderator responds to an authentication request.

Parameters:

  • requesterId: ID of the user who requested authentication
  • moderatorActed: Boolean indicating whether the moderator approved or rejected the request

Example:

samvyoInstance.on("moderatorAuthStatus", (data) => {
  console.log(`Moderator ${data.moderatorActed ? 'approved' : 'rejected'} authentication for ${data.requesterId}`);
  // Handle moderator's authentication decision
});

notification

Emitted for various notification events in the system.

Parameters:

  • eventType: Type of the notification event
  • eventText: Text message describing the notification

Example:

samvyoInstance.on("notification", (data) => {
  console.log(`Notification: ${data.eventText}`);
  // Handle notification based on eventType
});

processingStarted

Emitted when file processing begins.

Parameters:

  • processingStartTime: Timestamp when processing started
  • requestId: Unique identifier for the processing request

Example:

samvyoInstance.on("processingStarted", (data) => {
  console.log(`Processing started at ${new Date(data.processingStartTime)}`);
  console.log(`Request ID: ${data.requestId}`);
  // Handle processing start
});

processingCompleted

Emitted when file processing is successfully completed.

Parameters:

  • totalProcessingTime: Total time taken for processing in seconds
  • hlsFileKey: Key of the generated HLS file
  • size: Size of the processed file in MB
  • originalFile: Information about the original input file
  • lastFile: Boolean indicating if this is the last file in the processing array
  • requestId: The request identifier

Example:

samvyoInstance.on("processingCompleted", (data) => {
  console.log(`Processing completed in ${data.totalProcessingTime} seconds`);
  console.log(`HLS file key: ${data.hlsFileKey}`);
  console.log(`File size: ${data.size}MB`);
  console.log(`Is last file: ${data.lastFile}`);
  // Handle processing completion
});

processingError

Emitted when an error occurs during file processing.

Parameters:

  • totalProcessingTime: Time taken before the error occurred
  • hlsFileKey: Key of the HLS file (if any was generated)
  • size: Size of the processed file (if any)
  • originalFile: Information about the original input file
  • lastFile: Boolean indicating if this was the last file in the processing array
  • requestId: The request identifier
  • error: Error details

Example:

samvyoInstance.on("processingError", (data) => {
  console.error(`Processing failed for request ${data.requestId}`);
  console.error(`Error: ${data.error}`);
  console.log(`Processing time before error: ${data.totalProcessingTime} seconds`);
  // Handle processing error
});

customMessage

Emitted when a custom message is received from another peer. This event handles various message types including chat, widgets, room settings, and transcription.

Parameters:

  • data: The custom message payload (can be a string or object).
  • type: The type of the message (e.g., "chat", "widget", "custom", "transcription").
  • from: The ID of the sender.
  • messageType: The subtype of the message (e.g., "private", "public", "deepgram:transcript", "transcriptionOwnerChanged", "transcriptionStarted").
  • customData: Additional metadata (for widget messages).

Special Message Types:

Transcription Messages:

  • type: "transcription" and messageType: "transcriptionOwnerChanged" - Emitted when transcription ownership changes.
    • data.peerId: The ID of the new transcription owner.
  • type: "transcription" and messageType: "transcriptionStarted" - Emitted when transcription starts.
    • data.peerId: The ID of the transcription owner.
  • type: "transcription" and messageType: "deepgram:transcript" - Emitted when a transcription result is received.
    • data.transcript or data.text: The transcribed text.
    • data.is_final or data.isFinal: Boolean indicating if the result is final.
    • data.speaker or from: The ID of the speaker.

Room Settings Messages:

  • messageType: "roomSetting:generalSettings" - General room settings updates.
  • messageType: "roomSetting:authSettings" - Authentication settings updates.
  • messageType: "roomSetting:stageSettings" - Stage mode settings updates.
  • messageType: "roomSetting:presenterSettings" - Presenter permissions updates.
  • messageType: "roomSetting:participantSettings" - Participant permissions updates.

Example:

samvyoInstance.on("customMessage", async (message) => {
  console.log(`Received custom message from ${message.from}:`, message.data);
  
  // Handle transcription messages
  if (message.type === "transcription" && message.messageType === "deepgram:transcript") {
    const transcript = typeof message.data === "string" 
      ? JSON.parse(message.data) 
      : message.data;
    console.log(`Transcript: ${transcript.transcript || transcript.text}`);
  }
  
  // Handle room settings
  if (message.messageType?.startsWith('roomSetting:')) {
    console.log("Room settings updated:", message.data);
  }
});

participantUpgraded

Emitted when a participant is upgraded to a presenter.

Parameters:

  • peerId: The ID of the upgraded peer.
  • audioStatus: Boolean, if audio is enabled.
  • videoStatus: Boolean, if video is enabled.
  • participantType: "presenter".

Example:

samvyoInstance.on("participantUpgraded", (data) => {
  console.log(`Peer ${data.peerId} upgraded to presenter.`);
});

participantDowngraded

Emitted when a participant is downgraded to a viewer.

Parameters:

  • peerId: The ID of the downgraded peer.
  • participantType: "viewer".

Example:

samvyoInstance.on("participantDowngraded", (data) => {
  console.log(`Peer ${data.peerId} downgraded to viewer.`);
});

upgraded

Emitted to the local user when they are upgraded to a presenter.

Parameters:

  • audioStatus: Boolean, if audio is enabled.
  • videoStatus: Boolean, if video is enabled.
  • participantType: "presenter".

Example:

samvyoInstance.on("upgraded", (data) => {
  console.log("I have been upgraded to presenter!", data);
});

upgradeRequestSent

Emitted when an upgrade request is successfully sent.

Parameters:

  • status: The status of the request (e.g., "success").
  • message: Optional message string.

Example:

samvyoInstance.on("upgradeRequestSent", ({ status, message }) => {
  if (status === 'success') {
    console.log('Upgrade request successfully sent to moderators');
  }
});

upgradeRequestRejected

Emitted when a moderator rejects an upgrade request.

Parameters:

  • moderatorPeerId: The ID of the moderator who rejected the request.

Example:

samvyoInstance.on("upgradeRequestRejected", (data) => {
  console.log(`Upgrade request rejected by ${data.moderatorPeerId}`);
});

handRaise

Emitted when a peer raises or lowers their hand.

Parameters:

  • peerId: The ID of the peer who raised/lowered their hand.
  • handRaised: Boolean indicating if the hand is raised (true) or lowered (false).
  • peerName: The name of the peer.
  • upgradeRequest: Boolean indicating if this hand raise is also an upgrade request.

Example:

samvyoInstance.on("handRaise", ({ peerId, handRaised, peerName, upgradeRequest }) => {
  if (handRaised) {
    console.log(`Peer ${peerName} (${peerId}) raised their hand`);
    if (upgradeRequest) {
      console.log("This is also an upgrade request");
    }
  } else {
    console.log(`Peer ${peerName} (${peerId}) lowered their hand`);
  }
});

handRaised

Emitted when a peer raises their hand. (Deprecated - use handRaise event instead)

Parameters:

  • peerId: The ID of the peer who raised their hand.

Example:

samvyoInstance.on("handRaised", ({ peerId }) => {
  console.log(`Peer ${peerId} raised their hand.`);
});

handDropped

Emitted when a peer's hand is lowered. (Deprecated - use handRaise event instead)

Parameters:

  • peerId: The ID of the peer whose hand was lowered.
  • moderator: Boolean, true if lowered by a moderator.

Example:

samvyoInstance.on("handDropped", ({ peerId, moderator }) => {
  console.log(`Peer ${peerId} hand lowered. Moderator action: ${moderator}`);
});

modUpgradeReq

Emitted when a moderator receives an upgrade request from a viewer, or when a viewer receives an upgrade request from a moderator.

Parameters (for moderators):

  • peerId: The ID of the peer requesting upgrade.
  • peerName: The name of the peer requesting upgrade.
  • roomName: The name of the room.
  • timestamp: Timestamp when the request was made.

Parameters (for viewers):

  • peerId: The ID of the viewer receiving the request.
  • status: Boolean indicating if the request is active.
  • moderator: The ID of the moderator sending the request.

Example:

// For moderators
samvyoInstance.on("modUpgradeReq", ({ peerId, peerName, roomName, timestamp }) => {
  console.log(`Received upgrade request from ${peerName} in room ${roomName}`);
  // Show notification to moderator
});
 
// For viewers
samvyoInstance.on("modUpgradeReq", ({ peerId, status, moderator }) => {
  if (peerId === myPeerId && status) {
    console.log("Moderator is requesting me to upgrade to presenter");
    // Show upgrade request dialog
  }
});

roleChanged

Emitted when a peer's role changes (e.g., from viewer to presenter).

Parameters:

  • peerId: The ID of the peer whose role changed.
  • role: The new role (e.g., "presenter", "viewer").

Example:

samvyoInstance.on("roleChanged", async ({ peerId, role }) => {
  const myId = samvyoInstance.data?.inputParams?.peerId;
  if (peerId === myId && role === 'presenter') {
    console.log('Role changed to presenter - enabling media production');
    await samvyoInstance.enableMic();
    await samvyoInstance.enableCam();
  } else if (peerId === myId && role === 'viewer') {
    console.log('Role changed to viewer - disabling media production');
    await samvyoInstance.disableMic();
    await samvyoInstance.disableCam();
  }
});

upgradeRequestReceived

Emitted when a viewer receives an upgrade request from a moderator.

Parameters:

  • peerId: The ID of the viewer receiving the request.
  • moderator: The ID of the moderator sending the request.
  • message: Optional message from the moderator.

Example:

samvyoInstance.on("upgradeRequestReceived", ({ peerId, moderator, message }) => {
  console.log("Upgrade request received from moderator:", moderator);
  // Show upgrade request dialog to viewer
});

upgradeRequestCancelled

Emitted when a moderator cancels an upgrade request they sent to a viewer.

Parameters:

  • peerId: The ID of the viewer for whom the request was cancelled.
  • moderator: The ID of the moderator who cancelled the request.
  • message: Optional message explaining the cancellation.

Example:

samvyoInstance.on("upgradeRequestCancelled", ({ peerId, moderator, message }) => {
  console.log("Upgrade request cancelled:", message);
  // Hide upgrade request dialog
});

upgradeRequestRejected

Emitted when a viewer rejects an upgrade request from a moderator.

Parameters:

  • peerId: The ID of the viewer who rejected the request.
  • moderator: The ID of the moderator who sent the request.
  • message: Optional message explaining the rejection.

Example:

samvyoInstance.on("upgradeRequestRejected", ({ peerId, moderator, message }) => {
  console.log("Upgrade request rejected:", message);
  // Notify moderator that request was rejected
});

peersWaiting

Emitted when there are peers waiting in the lobby (for locked rooms or approval).

Parameters:

  • peersWaiting: Array of waiting peer objects.
  • count: Number of waiting peers.

Example:

samvyoInstance.on("peersWaiting", ({ peersWaiting, count }) => {
  console.log(`${count} peers are waiting to join.`);
});

roomClosed

Emitted when the room is closed by a moderator or the system.

Parameters:

  • roomId: The ID of the closed room.
  • reason: Reason for closure (e.g., "removed_by_moderator").

Example:

samvyoInstance.on("roomClosed", (data) => {
  console.log("Room closed:", data.reason);
});

roomLockStatusChanged

Emitted when the room is locked or unlocked by a moderator.

Parameters:

  • locked: Boolean, true if the room is locked.
  • message: Status message string.

Example:

samvyoInstance.on("roomLockStatusChanged", ({ locked, message }) => {
  console.log(`Room is now ${locked ? 'locked' : 'unlocked'}: ${message}`);
});

upgradeLimitReached

Emitted when a participant cannot be upgraded because the maximum number of presenters has been reached.

Parameters:

  • limit: The maximum number of presenters allowed.
  • message: Error message string.

Example:

samvyoInstance.on("upgradeLimitReached", ({ limit, message }) => {
  console.warn(`Cannot upgrade: ${message}. Limit is ${limit}.`);
});

screenShareLimitReached

Emitted when a user tries to share their screen but the room's limit for simultaneous screen shares has been reached.

Parameters:

  • limit: The maximum number of screen shares allowed.
  • message: Error message string.

Example:

samvyoInstance.on("screenShareLimitReached", ({ limit, message }) => {
  console.warn(`Cannot share screen: ${message}. Limit is ${limit}.`);
});

micForcedOff

Emitted when the moderator forcefully mutes the local user's microphone.

Parameters:

  • message: Notification message string.

Example:

samvyoInstance.on("micForcedOff", ({ message }) => {
  console.log("Microphone was muted by moderator:", message);
});