modified lib-jitsi-meet dev repo
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.

strophe.rayo.js 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. /* jshint -W117 */
  2. var logger = require("jitsi-meet-logger").getLogger(__filename);
  3. module.exports = function() {
  4. Strophe.addConnectionPlugin('rayo',
  5. {
  6. RAYO_XMLNS: 'urn:xmpp:rayo:1',
  7. connection: null,
  8. init: function (conn) {
  9. this.connection = conn;
  10. if (this.connection.disco) {
  11. this.connection.disco.addFeature('urn:xmpp:rayo:client:1');
  12. }
  13. this.connection.addHandler(
  14. this.onRayo.bind(this), this.RAYO_XMLNS, 'iq', 'set', null, null);
  15. },
  16. onRayo: function (iq) {
  17. logger.info("Rayo IQ", iq);
  18. },
  19. dial: function (to, from, roomName, roomPass) {
  20. var self = this;
  21. var req = $iq(
  22. {
  23. type: 'set',
  24. to: this.connection.emuc.focusMucJid
  25. }
  26. );
  27. req.c('dial',
  28. {
  29. xmlns: this.RAYO_XMLNS,
  30. to: to,
  31. from: from
  32. });
  33. req.c('header',
  34. {
  35. name: 'JvbRoomName',
  36. value: roomName
  37. }).up();
  38. if (roomPass !== null && roomPass.length) {
  39. req.c('header',
  40. {
  41. name: 'JvbRoomPassword',
  42. value: roomPass
  43. }).up();
  44. }
  45. this.connection.sendIQ(
  46. req,
  47. function (result) {
  48. logger.info('Dial result ', result);
  49. var resource = $(result).find('ref').attr('uri');
  50. this.call_resource = resource.substr('xmpp:'.length);
  51. logger.info(
  52. "Received call resource: " + this.call_resource);
  53. },
  54. function (error) {
  55. logger.info('Dial error ', error);
  56. }
  57. );
  58. },
  59. hang_up: function () {
  60. if (!this.call_resource) {
  61. logger.warn("No call in progress");
  62. return;
  63. }
  64. var self = this;
  65. var req = $iq(
  66. {
  67. type: 'set',
  68. to: this.call_resource
  69. }
  70. );
  71. req.c('hangup',
  72. {
  73. xmlns: this.RAYO_XMLNS
  74. });
  75. this.connection.sendIQ(
  76. req,
  77. function (result) {
  78. logger.info('Hangup result ', result);
  79. self.call_resource = null;
  80. },
  81. function (error) {
  82. logger.info('Hangup error ', error);
  83. self.call_resource = null;
  84. }
  85. );
  86. }
  87. }
  88. );
  89. };