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.

JingleSession.js 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. /*
  2. * JingleSession provides an API to manage a single Jingle session. We will
  3. * have different implementations depending on the underlying interface used
  4. * (i.e. WebRTC and ORTC) and here we hold the code common to all of them.
  5. */
  6. function JingleSession(me, sid, connection, service, eventEmitter) {
  7. /**
  8. * Our JID.
  9. */
  10. this.me = me;
  11. /**
  12. * The Jingle session identifier.
  13. */
  14. this.sid = sid;
  15. /**
  16. * The XMPP connection.
  17. */
  18. this.connection = connection;
  19. /**
  20. * The XMPP service.
  21. */
  22. this.service = service;
  23. /**
  24. * The event emitter.
  25. */
  26. this.eventEmitter = eventEmitter;
  27. /**
  28. * Whether to use dripping or not. Dripping is sending trickle candidates
  29. * not one-by-one.
  30. * Note: currently we do not support 'false'.
  31. */
  32. this.usedrip = true;
  33. /**
  34. * When dripping is used, stores ICE candidates which are to be sent.
  35. */
  36. this.drip_container = [];
  37. // Media constraints. Is this WebRTC only?
  38. this.media_constraints = null;
  39. // ICE servers config (RTCConfiguration?).
  40. this.ice_config = {};
  41. // The chat room instance associated with the session.
  42. this.room = null;
  43. }
  44. /**
  45. * Prepares this object to initiate a session.
  46. * @param peerjid the JID of the remote peer.
  47. * @param isInitiator whether we will be the Jingle initiator.
  48. * @param media_constraints
  49. * @param ice_config
  50. */
  51. JingleSession.prototype.initialize = function(peerjid, isInitiator,
  52. media_constraints, ice_config) {
  53. this.media_constraints = media_constraints;
  54. this.ice_config = ice_config;
  55. if (this.state !== null) {
  56. console.error('attempt to initiate on session ' + this.sid +
  57. 'in state ' + this.state);
  58. return;
  59. }
  60. this.state = 'pending';
  61. this.initiator = isInitiator ? this.me : peerjid;
  62. this.responder = !isInitiator ? this.me : peerjid;
  63. this.peerjid = peerjid;
  64. this.doInitialize();
  65. };
  66. /**
  67. * Finishes initialization.
  68. */
  69. JingleSession.prototype.doInitialize = function() {};
  70. /**
  71. * Adds the ICE candidates found in the 'contents' array as remote candidates?
  72. * Note: currently only used on transport-info
  73. */
  74. JingleSession.prototype.addIceCandidates = function(contents) {};
  75. /**
  76. * Handles an 'add-source' event.
  77. *
  78. * @param contents an array of Jingle 'content' elements.
  79. */
  80. JingleSession.prototype.addSources = function(contents) {};
  81. /**
  82. * Handles a 'remove-source' event.
  83. *
  84. * @param contents an array of Jingle 'content' elements.
  85. */
  86. JingleSession.prototype.removeSources = function(contents) {};
  87. /**
  88. * Terminates this Jingle session (stops sending media and closes the streams?)
  89. */
  90. JingleSession.prototype.terminate = function() {};
  91. /**
  92. * Sends a Jingle session-terminate message to the peer and terminates the
  93. * session.
  94. * @param reason
  95. * @param text
  96. */
  97. JingleSession.prototype.sendTerminate = function(reason, text) {};
  98. /**
  99. * Handles an offer from the remote peer (prepares to accept a session).
  100. * @param jingle the 'jingle' XML element.
  101. */
  102. JingleSession.prototype.setOffer = function(jingle) {};
  103. /**
  104. * Handles an answer from the remote peer (prepares to accept a session).
  105. * @param jingle the 'jingle' XML element.
  106. */
  107. JingleSession.prototype.setAnswer = function(jingle) {};
  108. module.exports = JingleSession;