Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

ParticipantConnectionStatus.js 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* global __filename, module, require */
  2. var logger = require("jitsi-meet-logger").getLogger(__filename);
  3. var RTCEvents = require("../../service/RTC/RTCEvents");
  4. import * as JitsiConferenceEvents from "../../JitsiConferenceEvents";
  5. /**
  6. * Class is responsible for emitting
  7. * JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED events.
  8. *
  9. * @constructor
  10. * @param rtc {RTC} the RTC service instance
  11. * @param conference {JitsiConference} parent conference instance
  12. */
  13. function ParticipantConnectionStatus(rtc, conference) {
  14. this.rtc = rtc;
  15. this.conference = conference;
  16. rtc.addListener(
  17. RTCEvents.ENDPOINT_CONN_STATUS_CHANGED,
  18. this.onEndpointConnStatusChanged.bind(this));
  19. }
  20. /**
  21. * Handles RTCEvents.ENDPOINT_CONN_STATUS_CHANGED triggered when we receive
  22. * notification over the data channel from the bridge about endpoint's
  23. * connection status update.
  24. * @param endpointId {string} the endpoint ID(MUC nickname/resource JID)
  25. * @param status {boolean} true if the connection is OK or false otherwise
  26. */
  27. ParticipantConnectionStatus.prototype.onEndpointConnStatusChanged
  28. = function(endpointId, status) {
  29. logger.debug(
  30. 'Detector RTCEvents.ENDPOINT_CONN_STATUS_CHANGED(' + Date.now() +'): '
  31. + endpointId +": " + status);
  32. // Filter out events for the local JID for now
  33. if (endpointId !== this.conference.myUserId()) {
  34. this._changeConnectionStatus(endpointId, status);
  35. }
  36. };
  37. ParticipantConnectionStatus.prototype._changeConnectionStatus
  38. = function (endpointId, newStatus) {
  39. var participant = this.conference.getParticipantById(endpointId);
  40. if (!participant) {
  41. // This will happen when participant exits the conference with broken
  42. // ICE connection and we join after that. The bridge keeps sending
  43. // that notification until the conference does not expire.
  44. logger.warn(
  45. 'Missed participant connection status update - ' +
  46. 'no participant for endpoint: ' + endpointId);
  47. return;
  48. }
  49. if (participant.isConnectionActive() !== newStatus) {
  50. participant._setIsConnectionActive(newStatus);
  51. logger.debug(
  52. 'Emit endpoint conn status(' + Date.now() + '): ',
  53. endpointId, newStatus);
  54. this.conference.eventEmitter.emit(
  55. JitsiConferenceEvents.PARTICIPANT_CONN_STATUS_CHANGED,
  56. endpointId, newStatus);
  57. }
  58. };
  59. module.exports = ParticipantConnectionStatus;