Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Listen to webrtcsdk events on https://apps.mypurecloud.com.au/ native softphone #713

Open
yamanoj opened this issue Jun 8, 2022 · 3 comments

Comments

@yamanoj
Copy link

yamanoj commented Jun 8, 2022

I created the following simple app to test webrtcsdk event listeners and it is working fine:

        var scriptElem  = document.createElement('script'),
        head = document.head || document.getElementsByTagName('head')[0];
        scriptElem.src = 'https://sdk-cdn.mypurecloud.com/webrtc-sdk/v6/genesys-cloud-webrtc-sdk.bundle.min.js';
        scriptElem.async = false;

        head.insertBefore(scr, head.firstChild);

        scriptElem.addEventListener('load', () => {
            const sdk = new window.GenesysCloudWebrtcSdk({
                accessToken: ".......",
                environment: "mypurecloud.com.au"

            });

            sdk.on('sessionStarted', (e) => { console.log('SESSION STARTED' , e) });

            sdk.initialize().then(async () => {
                await sdk.startSoftphoneSession({phoneNumber: 'XXXXXXX'});
            });
        })

I want to listen to the webrtcsdk events on https://apps.mypurecloud.com.au/ native softphone. I found an sdk object set as a window variable on one of the frames. However, I couldn't get working when I did the following:

window._webrtcsdk.on('sessionStarted', (e) => { console.log('SESSION STARTED' , e) });

What do you think is the best way to get this working?

@djhouseknecht
Copy link
Contributor

djhouseknecht commented Jun 9, 2022

@yamanoj when you say:

I want to listen to the webrtcsdk events on https://apps.mypurecloud.com.au/ native softphone. I found an sdk object set as a window variable on one of the frames. However, I couldn't get working when I did the following...

What is the full url you are on?

It almost sounds like you are in the main Genesys Cloud web application and you found the sdk object that our video iframe is using, which is why when you listen to sessionStarted, you aren't getting anything. In order for window._webrtcsdk.on('sessionStarted', ...) to fire, you have to have accepted the webrtc session using that sdk instance (ie. using window._webrtcsdk). The one that I think you found on the iframe window only handles the video webrtc sessions.

@yamanoj
Copy link
Author

yamanoj commented Jun 9, 2022

The full URL goes like https://apps.mypurecloud.com.au/directory/#/person/xxx

Yeah, this makes sense. The sdk (window_webrtcsdk) object might not be associated with the actual softphone. But unfortunately, sdk object is not exposed on any other windows/iframes.

What I want is to listen to the events like call start/end/mute/unmute etc. Do you have any mechanism for this?

@djhouseknecht
Copy link
Contributor

djhouseknecht commented Jun 14, 2022

@yamanoj, you want to listen to sdk events inside the main Genesys Cloud application?

It seems a little odd to hook into the sdk of another app to listen to call events. Can I ask what your use case is?

Currently, the main application is not using the SDK for softphone. We are working towards implementing it, but it is a slow process.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants