[6a3a178] | 1 | 'use strict';
|
---|
| 2 |
|
---|
| 3 | // The simplest and most robust transport, using the well-know cross
|
---|
| 4 | // domain hack - JSONP. This transport is quite inefficient - one
|
---|
| 5 | // message could use up to one http request. But at least it works almost
|
---|
| 6 | // everywhere.
|
---|
| 7 | // Known limitations:
|
---|
| 8 | // o you will get a spinning cursor
|
---|
| 9 | // o for Konqueror a dumb timer is needed to detect errors
|
---|
| 10 |
|
---|
| 11 | var inherits = require('inherits')
|
---|
| 12 | , SenderReceiver = require('./lib/sender-receiver')
|
---|
| 13 | , JsonpReceiver = require('./receiver/jsonp')
|
---|
| 14 | , jsonpSender = require('./sender/jsonp')
|
---|
| 15 | ;
|
---|
| 16 |
|
---|
| 17 | function JsonPTransport(transUrl) {
|
---|
| 18 | if (!JsonPTransport.enabled()) {
|
---|
| 19 | throw new Error('Transport created when disabled');
|
---|
| 20 | }
|
---|
| 21 | SenderReceiver.call(this, transUrl, '/jsonp', jsonpSender, JsonpReceiver);
|
---|
| 22 | }
|
---|
| 23 |
|
---|
| 24 | inherits(JsonPTransport, SenderReceiver);
|
---|
| 25 |
|
---|
| 26 | JsonPTransport.enabled = function() {
|
---|
| 27 | return !!global.document;
|
---|
| 28 | };
|
---|
| 29 |
|
---|
| 30 | JsonPTransport.transportName = 'jsonp-polling';
|
---|
| 31 | JsonPTransport.roundTrips = 1;
|
---|
| 32 | JsonPTransport.needBody = true;
|
---|
| 33 |
|
---|
| 34 | module.exports = JsonPTransport;
|
---|