Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
mirhmousavi committed May 13, 2024
1 parent 90333f7 commit 3e91b16
Showing 1 changed file with 19 additions and 5 deletions.
24 changes: 19 additions & 5 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,10 +164,13 @@ function createVideochatButton() {
}


function createSurflySession(contactId, inviteType) {
function createSurflySession(contactId, inviteType, callback) {
var surflyMetadata = {
"name": "Customer"
};

callback && Surfly.on("session_started", function(session, event) { callback(session, event); });

if (inviteType == 'cobrowse') {
var regularSession = Surfly.session({
block_until_agent_joins: false
Expand Down Expand Up @@ -257,8 +260,13 @@ function loadSurfly() {
} = message;

if (data.type == 'ElevateToCobrowse' && data.bu == nicBusNumber && data.uniquePageId == localStorage.getItem(nicBusNumber + "-uniquePageId")) {
createSurflySession(data.contactId, 'cobrowse');

createSurflySession(data.contactId, 'cobrowse', (session, event) => {
cobrowseRoom.publish({
type: event,
unique_page_id: localStorage.getItem(nicBusNumber + "-uniquePageId"),
follower_link: session.followerLink,
});
});
console.log('Co-browsing session requested');
console.log("Message ID: " + id);
console.log("Timestamp: " + timestamp);
Expand Down Expand Up @@ -294,7 +302,13 @@ function loadSurfly() {
} = message;

if (data.type == 'ElevateToVideo' && data.bu == nicBusNumber && data.uniquePageId == localStorage.getItem(nicBusNumber + "-uniquePageId")) {
createSurflySession(data.contactId, 'videochat');
createSurflySession(data.contactId, 'videochat', (session, event) => {
videoRoom.publish({
type: event,
unique_page_id: localStorage.getItem(nicBusNumber + "-uniquePageId"),
follower_link: session.followerLink,
});
});

console.log('Videochat session requested');
console.log("Message ID: " + id);
Expand Down Expand Up @@ -341,4 +355,4 @@ function initializeChatNiC() {
});

console.log('Initializing NiC');
}
}

0 comments on commit 3e91b16

Please sign in to comment.