You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

33 lines
791 B

4 years ago
  1. 'use strict';
  2. var inherits = require('inherits')
  3. , EventEmitter = require('events').EventEmitter
  4. , JSON3 = require('json3')
  5. , XHRLocalObject = require('./transport/sender/xhr-local')
  6. , InfoAjax = require('./info-ajax')
  7. ;
  8. function InfoReceiverIframe(transUrl) {
  9. var self = this;
  10. EventEmitter.call(this);
  11. this.ir = new InfoAjax(transUrl, XHRLocalObject);
  12. this.ir.once('finish', function(info, rtt) {
  13. self.ir = null;
  14. self.emit('message', JSON3.stringify([info, rtt]));
  15. });
  16. }
  17. inherits(InfoReceiverIframe, EventEmitter);
  18. InfoReceiverIframe.transportName = 'iframe-info-receiver';
  19. InfoReceiverIframe.prototype.close = function() {
  20. if (this.ir) {
  21. this.ir.close();
  22. this.ir = null;
  23. }
  24. this.removeAllListeners();
  25. };
  26. module.exports = InfoReceiverIframe;