From 3d95b381997739826bcf0a5680aa838496128307 Mon Sep 17 00:00:00 2001 From: Mirhossein Mousavi Date: Fri, 3 May 2024 15:34:46 +0200 Subject: [PATCH] wip --- main.js | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/main.js b/main.js index cdd1d20..7c8e9aa 100644 --- a/main.js +++ b/main.js @@ -243,16 +243,16 @@ function loadSurfly() { console.log("Connection has been opened"); - const adminapiCobrowseRoom = drone.subscribe('adminapi-cobrowse'); - adminapiCobrowseRoom.on('open', error => { + const adminAPIRoom = drone.subscribe('adminAPI'); + adminAPIRoom.on('open', error => { if (error) { return console.error(error); } else { - console.log("Admin API Cobrowse room has been opened"); + console.log("Admin API room has been opened"); } }); - adminapiCobrowseRoom.on('message', message => { + adminAPIRoom.on('message', message => { const nic_contact_id = message.data.nic_contact_id; if (message.data.unique_page_id === getOrCreateUniqueClientID()) { Surfly.on('session_created', function(session, event) { @@ -263,20 +263,22 @@ function loadSurfly() { "Content-Type": "application/json", }, body: JSON.stringify({ - follower_link: session.followerLink, cluster_nic: clusterNiC, nic_contact_id: nic_contact_id, + follower_link: session.followerLink, + pin: session.pin, }), } - ).then(response => { - return response.json(); - }).then(result => { - console.log("Success:", result); - }).catch(error => { + ).catch(error => { console.error("Error:", error); }); }); - createSurflySession(nic_contact_id, 'cobrowse', false); + if (message.data.type === 'cobrowse') + createSurflySession(nic_contact_id, 'cobrowse', false); + else if (message.data.type === 'videochat') + createSurflySession(nic_contact_id, 'videochat', false); + else: + console.error("Invalid type of session requested"); } });