diff --git a/public/bundle.js b/public/bundle.js index 4c5e2b6..8288646 100644 --- a/public/bundle.js +++ b/public/bundle.js @@ -20654,9 +20654,8 @@ module.exports = yeast; module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', mediasoupAddress: 'https://video.safemobile.org/mediasoup', -} - - + // mediasoupAddress: 'http://localhost:3000/mediasoup', +} },{}],96:[function(require,module,exports){ const io = require('socket.io-client') const mediasoupClient = require('mediasoup-client') @@ -20675,7 +20674,12 @@ hub = io(config.hubAddress) const connectToMediasoup = () => { - socket = io(config.mediasoupAddress) + socket = io(config.mediasoupAddress, { + reconnection: true, + reconnectionDelay: 1000, + reconnectionDelayMax : 5000, + reconnectionAttempts: Infinity + }) socket.on('connection-success', ({ _socketId, existsProducer }) => { console.log(`[MEDIA] ${config.mediasoupAddress} | connected: ${socket.connected} | existsProducer: ${existsProducer}`) @@ -20703,17 +20707,32 @@ if (IS_PRODUCER === true) { hub.on('video', (data) => { const parsedData = JSON.parse(data); + + if (parsedData.type === 'notify-request') { console.log('video', parsedData) originAssetId = parsedData.origin_asset_id; originAssetName = parsedData.origin_asset_name; originAssetTypeName = parsedData.origin_asset_type_name; callId = parsedData.video_call_id; - console.log('IS_PRODUCER', IS_PRODUCER, 'callId', callId); - - if (parsedData.type === 'notify-request' && IS_PRODUCER) { + console.log('[VIDEO] notify-request | IS_PRODUCER', IS_PRODUCER, 'callId', callId); getLocalStream() } + + if (parsedData.type === 'notify-end') { + // NOT WORKING + localVideo.srcObject = null + remoteVideo.srcObject = null + console.log('[VIDEO] notify-end | IS_PRODUCER', IS_PRODUCER, 'callId', callId); + // socket.emit('transportclose') + socket.emit('transportclose') + consumer = null + producer = null + producerTransport = null + consumerTransport = null + device = null + socket.destroy() + } }) }) @@ -20770,6 +20789,7 @@ let params = { } const streamSuccess = (stream) => { + console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] params = { @@ -20812,6 +20832,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { + console.log('[createDevice]'); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -20834,6 +20855,7 @@ const createDevice = async () => { } const getRtpCapabilities = () => { + console.log('[getRtpCapabilities]'); // make a request to the server for Router RTP Capabilities // see server's socket.on('getRtpCapabilities', ...) // the server sends back data object which contains rtpCapabilities @@ -20921,7 +20943,6 @@ const connectSendTransport = async () => { producer.on('trackended', () => { console.log('track ended') - // close video track }) diff --git a/public/config.js b/public/config.js index d2e2d91..d12c148 100644 --- a/public/config.js +++ b/public/config.js @@ -1,4 +1,5 @@ module.exports = { hubAddress: 'https://hub.dev.linx.safemobile.com/', mediasoupAddress: 'https://video.safemobile.org/mediasoup', + // mediasoupAddress: 'http://localhost:3000/mediasoup', } \ No newline at end of file diff --git a/public/index.js b/public/index.js index db9ba18..d9713eb 100644 --- a/public/index.js +++ b/public/index.js @@ -130,6 +130,7 @@ let params = { } const streamSuccess = (stream) => { + console.log('[streamSuccess]'); localVideo.srcObject = stream const track = stream.getVideoTracks()[0] params = { @@ -172,6 +173,7 @@ const goCreateTransport = () => { // server side to send/recive media const createDevice = async () => { try { + console.log('[createDevice]'); device = new mediasoupClient.Device() // https://mediasoup.org/documentation/v3/mediasoup-client/api/#device-load @@ -194,6 +196,7 @@ const createDevice = async () => { } const getRtpCapabilities = () => { + console.log('[getRtpCapabilities]'); // make a request to the server for Router RTP Capabilities // see server's socket.on('getRtpCapabilities', ...) // the server sends back data object which contains rtpCapabilities