onsip / SIP.js

A simple, intuitive, and powerful JavaScript signaling library
https://sipjs.com
MIT License
1.84k stars 693 forks source link

shared/persistent websockets on multiple tabs #1060

Open dberardo-com opened 8 months ago

dberardo-com commented 8 months ago

it would be nice to have the following possibilities:

Bill-Niz commented 8 months ago

@dberardo-com you can use ServiceWorkers Use WebSockets in service workers service-worker-web-socket

dberardo-com commented 8 months ago

would this be a solution for both problems above ?

and how can service workers be used with this library ? i had the same thought of using service workers, but i dont get how to include it in this library ...should i fork it in order to achieve this ?

Bill-Niz commented 8 months ago

Maybe setting up sipjs inside service worker Or setup custom websocket transport inside serve worker and use it in sipjs

dberardo-com commented 8 months ago

i need to use sipjs in the client application, so the first option you are suggesting sound too complex to mantain for me, meaning that the interaction with the service worker would need to be fully event based and that would mean too much refactoring. as for this one:

Or setup custom websocket transport inside serve worker and use it in sipjs

i am not sure i got it, do you mean opening up a websocket in the webworker and then pass its reference to the specific window that needs it ? is this even possible (i am thinking security limits or so)?

and how to pass the websoket object in the sipjs options ? is it allowed ?


also: what motivates this is the fact that SIP does not allow the same user to register twice (at least not in my case, let me know if this is not correct), and so the only way to let the user use sipjs on multiple tabs at the same time needs to be via a shared websocket as we cannot have 2 parallel registration with the same sipId.