surflion-service 1.1.0 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/surflion.js +20 -21
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "surflion-service",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "",
5
5
  "main": "surflion.js",
6
6
  "scripts": {
package/surflion.js CHANGED
@@ -1486,13 +1486,6 @@ var SurfLion = {
1486
1486
  }
1487
1487
  SurfLion.incomingSession = data.session;
1488
1488
  SurfLion.eventHandlers.incoming(data)
1489
- const stream = new MediaStream();
1490
- const receivers = data.session.connection?.getReceivers();
1491
- if (receivers) {
1492
- receivers.forEach((receiver) => stream.addTrack(receiver.track));
1493
- }
1494
- SurfLion.localStream.srcObject = stream;
1495
- SurfLion.localStream.play();
1496
1489
  // SurfLion.ringtoneStream.play();
1497
1490
  } else {
1498
1491
  SurfLion.outgoingSession = data.session;
@@ -1500,13 +1493,6 @@ var SurfLion = {
1500
1493
  SurfLion.currentSession = SurfLion.outgoingSession;
1501
1494
  SurfLion.outgoingSession = null;
1502
1495
  SurfLion.eventHandlers.connecting(data)
1503
- const stream = new MediaStream();
1504
- const receivers = data.session.connection?.getReceivers();
1505
- if (receivers) {
1506
- receivers.forEach((receiver) => stream.addTrack(receiver.track));
1507
- }
1508
- SurfLion.localStream.srcObject = stream;
1509
- SurfLion.localStream.play();
1510
1496
  // SurfLion.ringtoneStream.play();
1511
1497
  });
1512
1498
  }
@@ -1524,13 +1510,13 @@ var SurfLion = {
1524
1510
  SurfLion.incomingSession = null;
1525
1511
  }
1526
1512
 
1527
- // const stream = new MediaStream();
1528
- // const receivers = data.session.connection?.getReceivers();
1529
- // if (receivers) {
1530
- // receivers.forEach((receiver) => stream.addTrack(receiver.track));
1531
- // }
1532
- // SurfLion.localStream.srcObject = stream;
1533
- // SurfLion.localStream.play();
1513
+ const stream = new MediaStream();
1514
+ const receivers = data.session.connection?.getReceivers();
1515
+ if (receivers) {
1516
+ receivers.forEach((receiver) => stream.addTrack(receiver.track));
1517
+ }
1518
+ SurfLion.localStream.srcObject = stream;
1519
+ SurfLion.localStream.play();
1534
1520
  });
1535
1521
  data.session.on("failed", function (data) {
1536
1522
  // SurfLion.ringtoneStream.pause();
@@ -1546,6 +1532,19 @@ var SurfLion = {
1546
1532
  console.info('onSDP, type - ', data.type, ' sdp - ', data.sdp);
1547
1533
  }
1548
1534
  });
1535
+
1536
+ data.session.on('peerconnection', function (e) {
1537
+ console.log('peer connection');
1538
+
1539
+ e.peerconnection.addEventListener('track', function(event) {
1540
+ console.log('onaddstream');
1541
+ SurfLion.ringtoneStream.loop = false;
1542
+ SurfLion.ringtoneStream.src = null
1543
+ SurfLion.ringtoneStream.srcObject = event.streams[0];
1544
+ SurfLion.ringtoneStream.srcObject.play();
1545
+ });
1546
+ });
1547
+
1549
1548
  data.session.on('progress', function (data) {
1550
1549
  });
1551
1550
  });