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
Use Cases
Section titled “Use Cases”Getting Started
Section titled “Getting Started”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
Sessioninstance that Triggers the event - A JSON object with event attributes
// This will be Triggers for all sessions, including the restored oneswebfuse .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(); });session_created
Section titled “session_created”Triggers when a session is created (usually after space.session() call).
session_started
Section titled “session_started”Triggers when a session window has been loaded (usually after a call to session.start();). Has no additional parameters.
session_ended
Section titled “session_ended”Triggers when the session has been properly finished (normally after clicking the close button, or as a result of session.end() call).
Parameters
Section titled “Parameters”final_location
- On the leader side, URL of the last browsed page.
metadata_updated
Section titled “metadata_updated”Triggers when the session metadata is updated.
Parameters
Section titled “Parameters”metadata
- Object with the updated metadata values.
message
Section titled “message”Triggers when the message is received.
Parameters
Section titled “Parameters”data
- Message object sent from the other side.
origin
- The origin of the sender window.
host_rights_requested
Section titled “host_rights_requested”Triggers when host rights for the session had been requested.
Parameters
Section titled “Parameters”clientIndex
- Index of the user who requested control.
host_rights_refused
Section titled “host_rights_refused”Triggers when host rights for the session had been refused.
Parameters
Section titled “Parameters”clientIndex
- Index of the user whose request was refused.
host_changed
Section titled “host_changed”Triggers when host of the session has been changed.
Parameters
Section titled “Parameters”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.
file_downloaded
Section titled “file_downloaded”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.
Parameters
Section titled “Parameters”url
- Direct link to the downloaded file. File will be available until the end of the session.
filename - Name of the downloaded file.
chat_message
Section titled “chat_message”Triggers when a message is received from the chat.
Parameters
Section titled “Parameters”message
- Message received from the chat.
clientIndex
- Index of the user who sent the message
screen_resized
Section titled “screen_resized”Triggers every time the screen size of the session is changed.
Parameters
Section titled “Parameters”width
- The width of the screen.
height
- The height of the screen.
Participant Events
Section titled “Participant Events”participant_joined
Section titled “participant_joined”Triggers when a participant joins the session.
Parameters
Section titled “Parameters”clientIndex
- Index of the user. Can be used in subsequent
session.makeHost()calls.
userData
- Data provided in
userDataargument ofsession.start*()call.
participant_left
Section titled “participant_left”Triggers when a participant leaves the session.
Parameters
Section titled “Parameters”clientIndex
- Index of the user.
userData
- Data provided in
userDataargument ofsession.start*()call
user_activity
Section titled “user_activity”Triggers when master clicks, moves mouse, or presses any key. Triggers once per second if activity is present.
Tab Events
Section titled “Tab Events”tab_opened
Section titled “tab_opened”Triggers when a new tab with url is opened via session.openTab() api call.
Parameters
Section titled “Parameters”url
- Absolute URL of the new tab.
ssid
- SSID of the opened tab.
page_info
Section titled “page_info”Triggers when the page info is received from the cobrowsing session frame.
Parameters
Section titled “Parameters”title
- The title of the page.
tabId
- SSID of the tab.
new_tab_opened
Section titled “new_tab_opened”Triggers when a new tab page is opened.
tab_closed
Section titled “tab_closed”Triggers when a tab is closed.
Parameters
Section titled “Parameters”ssid
- SSID of the closed tab.
relocate_start
Section titled “relocate_start”(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.
Parameters
Section titled “Parameters”url
- Absolute URL loading webpage
relocated
Section titled “relocated”(not available inside a session)
Triggers when the current tab inside a virtual session navigates to another page.
Parameters
Section titled “Parameters”urlabsolute URL of new location
tab_relocated
Section titled “tab_relocated”Triggers when a tab is relocated to a new url. Not available for media sharing tabs (screen sharing, video camera sharing).
Parameters
Section titled “Parameters”url
- Absolute URL of the new location.
ssid
- SSID of the relocated tab.
tab_reloaded
Section titled “tab_reloaded”Triggers when a tab is reloaded. Not available for media sharing tabs (screen sharing, video camera sharing).
Parameters
Section titled “Parameters”url
- Absolute URL of the new location.
ssid
- SSID of the reloaded tab.
tab_paused
Section titled “tab_paused”Triggers when a tab is paused by the tab owner. See also tab_resumed event.
Parameters
Section titled “Parameters”leaderIndex
- Index of the participant who owns the tab.
ssid
- SSID of the paused tab.
tab_resumed
Section titled “tab_resumed”Triggers when a session is resumed after a pause. See also tab_paused event.
Parameters
Section titled “Parameters”leaderIndex
- Index of the participant who owns the tab.
ssid
- SSID of the resumed tab.
tab_activated
Section titled “tab_activated”Triggers when a tab is activated either by any means.
Parameters
Section titled “Parameters”ssid
- SSID of the activated tab.
tab_control_requested
Section titled “tab_control_requested”Triggers when control over the tab has been requested.
Parameters
Section titled “Parameters”clientIndex
- Index of the user who requested control.
ssid
- SSID of the tab that control has been requested for.
tab_control
Section titled “tab_control”Triggers when control over the tab has been transferred.
Parameters
Section titled “Parameters”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.
huddle_mode
Section titled “huddle_mode”Triggers when huddle mode is toggled.
Parameters
Section titled “Parameters”enabled
- Status of huddle mode (
boolean).
huddle_follow
Section titled “huddle_follow”Triggers when a when a participant follows another participant. This event is only trigged when huddle mode is enabled.
Parameters
Section titled “Parameters”client_index
- Index of the follower.
following_index
- Index of the parcipant the
client_indexis following.
(not available inside a session)
Triggers on common errors.
Parameters
Section titled “Parameters”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 thedetailsattribute of the event object for more information about the error."start_failed"Surfly session could not be started. Check thedetailsattribute of the event object for more information about the error.
popup_enabled
Section titled “popup_enabled”Triggers when the extension popup is enabled.
Parameters
Section titled “Parameters”extensionId
- ID of the extension that enabled the popup.
tabId
- ID of the tab that the popup is enabled for.
nullif the popup is enabled for all tabs.
popup_disabled
Section titled “popup_disabled”Triggers when the extension popup is disabled.
Parameters
Section titled “Parameters”extensionId
- ID of the extension that disabled the popup.
tabId
- ID of the tab that the popup is disabled for.
nullif the popup is disabled for all tabs.
popup_badge_text_set
Section titled “popup_badge_text_set”Triggers when the badge text of the extension popup is set.
Parameters
Section titled “Parameters”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.
nullif the badge text is set for all tabs.
popup_badge_background_color_set
Section titled “popup_badge_background_color_set”Triggers when the background color of the extension popup badge is set.
Parameters
Section titled “Parameters”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.
nullif the background color is set for all tabs.
popup_title_set
Section titled “popup_title_set”Triggers when the title of the extension popup is set.
Parameters
Section titled “Parameters”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.
nullif the title is set for all tabs.
popup_icon_set
Section titled “popup_icon_set”Triggers when the icon of the extension in the top bar is set.
Parameters
Section titled “Parameters”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.
nullif the icon is set for all tabs.
popup_set
Section titled “popup_set”Triggers when the popup of the extension is set.
Parameters
Section titled “Parameters”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.
nullif the popup is set for all tabs.
extension_side_panel_opened
Section titled “extension_side_panel_opened”Triggers when the extension side panel is opened.
Parameters
Section titled “Parameters”extensionId
- ID of the extension that opened the side panel.
tabId
- ID of the tab that the side panel is opened for.
nullif the side panel is opened for all tabs.
extension_side_panel_closed
Section titled “extension_side_panel_closed”Triggers when the extension side panel is closed.
Parameters
Section titled “Parameters”extensionId
- ID of the extension that closed the side panel.
tabId
- ID of the tab that the side panel is closed for.
nullif the side panel is closed for all tabs.
extension_side_panel_options_set
Section titled “extension_side_panel_options_set”Triggers when the options of the extension side panel are set.
Parameters
Section titled “Parameters”extensionId
- ID of the extension that set the side panel options.
options
- The options that were set.
optionsobject 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.nullif the side panel options are set for all tabs.
tabId
- ID of the tab that the side panel options are set for.
nullif the side panel options are set for all tabs.
extension_side_panel_layout_set
Section titled “extension_side_panel_layout_set”Triggers when the layout of the extension side panel is set.
Parameters
Section titled “Parameters”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
leftorright, default isright.
tabId
- ID of the tab that the side panel layout is set for.
nullif the side panel layout is set for all tabs.
extension_side_panel_behavior_set
Section titled “extension_side_panel_behavior_set”Triggers when the behavior of the extension side panel is set.
Parameters
Section titled “Parameters”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.
extension_refreshed
Section titled “extension_refreshed”Triggers when an Extension is refreshed in the Session.
Parameters
Section titled “Parameters”extension_id
- ID of the Extension that was refreshed.
extension_removed
Section titled “extension_removed”Triggers when an Extension is removed from the Session.
Parameters
Section titled “Parameters”extension_id
- ID of the Extension that was removed.