Projekt

Obecné

Profil

Stáhnout (791 Bajtů) Statistiky
| Větev: | Revize:
1
'use strict';
2

    
3
var inherits = require('inherits')
4
  , EventEmitter = require('events').EventEmitter
5
  , JSON3 = require('json3')
6
  , XHRLocalObject = require('./transport/sender/xhr-local')
7
  , InfoAjax = require('./info-ajax')
8
  ;
9

    
10
function InfoReceiverIframe(transUrl) {
11
  var self = this;
12
  EventEmitter.call(this);
13

    
14
  this.ir = new InfoAjax(transUrl, XHRLocalObject);
15
  this.ir.once('finish', function(info, rtt) {
16
    self.ir = null;
17
    self.emit('message', JSON3.stringify([info, rtt]));
18
  });
19
}
20

    
21
inherits(InfoReceiverIframe, EventEmitter);
22

    
23
InfoReceiverIframe.transportName = 'iframe-info-receiver';
24

    
25
InfoReceiverIframe.prototype.close = function() {
26
  if (this.ir) {
27
    this.ir.close();
28
    this.ir = null;
29
  }
30
  this.removeAllListeners();
31
};
32

    
33
module.exports = InfoReceiverIframe;
(5-5/12)