Skip to content

Session Events

Certain actions that happen within the session will trigger an event which can be tied to a certain Webhook defined by you.

But this can be extended further by yourself by leveraging our Virtual Web Extension API, allowing you to listen to certain Session events, such as when a session is started or the participant navigates to a new page. Next to that, each Session spins up its own Session API, such as: End the Session, Navigate to a Location, Load a Piece of Code, Send an API Message to Space Session

See the Session API reference for more information.

You can listen to and attach custom handler functions to events using webfuseSession.on(). Callback functions are provided with arguments, depending on the event type.

Session event handlers can be set with the webfuseSession.on() method, or with the global webfuse.on() method available from the Widget API. The latter will affect all existing and future sessions.

Callback functions should accept two arguments:

  • A Session instance that Triggers the event
  • A JSON object with event attributes
// This will be Triggers for all sessions, including the restored ones
webfuse
.on('session_ended', session => {
console.log(session, 'has ended');
});
webfuse
.initSpace('your_widget_key', 'your_space_id').then(async space => {
const session = space.session();
// Add event listeners
session.on('session_started', session => {
console.log('Session has started');
});
session.on('participant_joined', (session, event) => {
console.log('A participant joined with client index:', event.clientIndex);
});
session.on('session_ended', session => {
console.log('Session has ended');
});
// Start the session
await session.start();
});

Triggers when a session is created (usually after space.session() call).

Triggers when a session window has been loaded (usually after a call to session.start();). Has no additional parameters.

Triggers when the session has been properly finished (normally after clicking the close button, or as a result of session.end() call).

final_location

  • On the leader side, URL of the last browsed page.

Triggers when the session metadata is updated.

metadata

  • Object with the updated metadata values.

Triggers when the message is received.

data

  • Message object sent from the other side.

origin

  • The origin of the sender window.

Triggers when host rights for the session had been requested.

clientIndex

  • Index of the user who requested control.

Triggers when host rights for the session had been refused.

clientIndex

  • Index of the user whose request was refused.

Triggers when host of the session has been changed.

to

  • Index of the client that now is the host. Always 0 for the leader, 1 or more for a viewer.

gained

  • Set to true if host rights were given to the current user.

myIndex

  • Contains the user index of the current user_activity.

Triggers when a file download occurs inside the session. Note that this event is only fired when the user is controlling the session. This JS event is fired regardless of the download_trigger_enabled session option.

url

  • Direct link to the downloaded file. File will be available until the end of the session. filename
  • Name of the downloaded file.

Triggers when a message is received from the chat.

message

  • Message received from the chat.

clientIndex

  • Index of the user who sent the message

Triggers every time the screen size of the session is changed.

width

  • The width of the screen.

height

  • The height of the screen.

Triggers when a participant joins the session.

clientIndex

  • Index of the user. Can be used in subsequent session.makeHost() calls.

userData

  • Data provided in userData argument of session.start*() call.

Triggers when a participant leaves the session.

clientIndex

  • Index of the user.

userData

  • Data provided in userData argument of session.start*() call

Triggers when master clicks, moves mouse, or presses any key. Triggers once per second if activity is present.

Triggers when a new tab with url is opened via session.openTab() api call.

url

  • Absolute URL of the new tab.

ssid

  • SSID of the opened tab.

Triggers when the page info is received from the cobrowsing session frame.

title

  • The title of the page.

tabId

  • SSID of the tab.

Triggers when a new tab page is opened.

Triggers when a tab is closed.

ssid

  • SSID of the closed tab.

(not available inside a session)

Triggers when the current tab inside a virtual session starts loading a new page. In conjunction with the relocated event, it allows you to track page loading inside a cobrowsing session. For example, use it to show a custom loading indicator.

url

  • Absolute URL loading webpage

(not available inside a session)

Triggers when the current tab inside a virtual session navigates to another page.

  • url absolute URL of new location

Triggers when a tab is relocated to a new url. Not available for media sharing tabs (screen sharing, video camera sharing).

url

  • Absolute URL of the new location.

ssid

  • SSID of the relocated tab.

Triggers when a tab is reloaded. Not available for media sharing tabs (screen sharing, video camera sharing).

url

  • Absolute URL of the new location.

ssid

  • SSID of the reloaded tab.

Triggers when a tab is paused by the tab owner. See also tab_resumed event.

leaderIndex

  • Index of the participant who owns the tab.

ssid

  • SSID of the paused tab.

Triggers when a session is resumed after a pause. See also tab_paused event.

leaderIndex

  • Index of the participant who owns the tab.

ssid

  • SSID of the resumed tab.

Triggers when a tab is activated either by any means.

ssid

  • SSID of the activated tab.

Triggers when control over the tab has been requested.

clientIndex

  • Index of the user who requested control.

ssid

  • SSID of the tab that control has been requested for.

Triggers when control over the tab has been transferred.

leaderIndex

  • Index of the participant who owns the tab.

controlIndex

  • Index of the participant who controls the tab at the moment.

ssid

  • SSID of the tab that control has been transferred for.

Triggers when huddle mode is toggled.

enabled

  • Status of huddle mode (boolean).

Triggers when a when a participant follows another participant. This event is only trigged when huddle mode is enabled.

client_index

  • Index of the follower.

following_index

  • Index of the parcipant the client_index is following.

(not available inside a session)

Triggers on common errors.

reason

  • Error description. Currently may be one of the following:
  • "other_connection" the leader_link was opened elsewhere. The new window/browser becomes the leader and the old leader is kicked out. It also happens if follower_link was open twice in the same browser.
  • "connect_failed" The WebSocket connection to Surfly cannot be established.
  • "create_failed" Surfly session could not be created. Check the details attribute of the event object for more information about the error.
  • "start_failed" Surfly session could not be started. Check the details attribute of the event object for more information about the error.

Triggers when the extension popup is enabled.

extensionId

  • ID of the extension that enabled the popup.

tabId

  • ID of the tab that the popup is enabled for. null if the popup is enabled for all tabs.

Triggers when the extension popup is disabled.

extensionId

  • ID of the extension that disabled the popup.

tabId

  • ID of the tab that the popup is disabled for. null if the popup is disabled for all tabs.

Triggers when the badge text of the extension popup is set.

extensionId

  • ID of the extension that set the badge text.

text

  • The text to set as the badge text.

tabId

  • ID of the tab that the badge text is set for. null if the badge text is set for all tabs.

Triggers when the background color of the extension popup badge is set.

extensionId

  • ID of the extension that set the background color.

color

  • The background color to set as the badge color.

tabId

  • ID of the tab that the background color is set for. null if the background color is set for all tabs.

Triggers when the title of the extension popup is set.

extensionId

  • ID of the extension that set the title.

title

  • The title to set as the popup title.

tabId

  • ID of the tab that the title is set for. null if the title is set for all tabs.

Triggers when the icon of the extension in the top bar is set.

extensionId

  • ID of the extension that set the icon.

icon

  • The url of the icon that is set as the extension icon.

tabId

  • ID of the tab that the icon is set for. null if the icon is set for all tabs.

Triggers when the popup of the extension is set.

extensionId

  • ID of the extension that set the popup.

popup

  • The url of the popup that is set as the extension popup.

tabId

  • ID of the tab that the popup is set for. null if the popup is set for all tabs.

Triggers when the extension side panel is opened.

extensionId

  • ID of the extension that opened the side panel.

tabId

  • ID of the tab that the side panel is opened for. null if the side panel is opened for all tabs.

Triggers when the extension side panel is closed.

extensionId

  • ID of the extension that closed the side panel.

tabId

  • ID of the tab that the side panel is closed for. null if the side panel is closed for all tabs.

Triggers when the options of the extension side panel are set.

extensionId

  • ID of the extension that set the side panel options.

options

  • The options that were set. options object contains the following properties:
    • path: The path to the side panel template file relative to the root folder of the extension directory.
    • enabled: Whether the side panel is enabled.
    • tabId: ID of the tab that the side panel options are set for. null if the side panel options are set for all tabs.

tabId

  • ID of the tab that the side panel options are set for. null if the side panel options are set for all tabs.

Triggers when the layout of the extension side panel is set.

extensionId

  • ID of the extension that set the side panel layout.

side

  • The side of the extension side panel that was set. It must be either left or right, default is right.

tabId

  • ID of the tab that the side panel layout is set for. null if the side panel layout is set for all tabs.

Triggers when the behavior of the extension side panel is set.

extensionId

  • ID of the extension that set the side panel behavior.

openPanelOnActionClick

  • Whether the side panel should be opened on action click. Default value is false.

Triggers when an Extension is refreshed in the Session.

extension_id

  • ID of the Extension that was refreshed.

Triggers when an Extension is removed from the Session.

extension_id

  • ID of the Extension that was removed.