File tree Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Expand file tree Collapse file tree 4 files changed +22
-4
lines changed Original file line number Diff line number Diff line change @@ -410,7 +410,8 @@ class ConnectionManager extends EventEmitter {
410
410
411
411
static initTransports ( ) {
412
412
WebSocketTransport ( ConnectionManager ) ;
413
- Utils . arrForEach ( Platform . Transports , function ( initFn ) {
413
+ Utils . arrForEach ( Platform . Transports . order , function ( transportName ) {
414
+ const initFn = Platform . Transports . implementations [ transportName ] ! ;
414
415
initFn ( ConnectionManager ) ;
415
416
} ) ;
416
417
}
Original file line number Diff line number Diff line change @@ -7,11 +7,14 @@ import IBufferUtils from './types/IBufferUtils';
7
7
import * as WebBufferUtils from '../platform/web/lib/util/bufferutils' ;
8
8
import * as NodeBufferUtils from '../platform/nodejs/lib/util/bufferutils' ;
9
9
import { IUntypedCryptoStatic } from '../common/types/ICryptoStatic' ;
10
+ import TransportName from './constants/TransportName' ;
10
11
11
12
type Bufferlike = WebBufferUtils . Bufferlike | NodeBufferUtils . Bufferlike ;
12
13
type BufferUtilsOutput = WebBufferUtils . Output | NodeBufferUtils . Output ;
13
14
type ToBufferOutput = WebBufferUtils . ToBufferOutput | NodeBufferUtils . ToBufferOutput ;
14
15
16
+ export type TransportImplementations = Partial < Record < TransportName , TransportInitialiser > > ;
17
+
15
18
export default class Platform {
16
19
static Config : IPlatformConfig ;
17
20
/*
@@ -29,7 +32,10 @@ export default class Platform {
29
32
*/
30
33
static Crypto : IUntypedCryptoStatic | null ;
31
34
static Http : typeof IHttp ;
32
- static Transports : TransportInitialiser [ ] ;
35
+ static Transports : {
36
+ order : TransportName [ ] ;
37
+ implementations : TransportImplementations ;
38
+ } ;
33
39
static Defaults : IDefaults ;
34
40
static WebStorage : IWebStorage | null ;
35
41
}
Original file line number Diff line number Diff line change
1
+ import TransportName from 'common/constants/TransportName' ;
1
2
import initialiseNodeCometTransport from './nodecomettransport' ;
2
3
3
- export default [ initialiseNodeCometTransport ] ;
4
+ export default {
5
+ order : [ TransportName . Comet ] ,
6
+ implementations : { [ TransportName . Comet ] : initialiseNodeCometTransport } ,
7
+ } ;
Original file line number Diff line number Diff line change
1
+ import TransportName from 'common/constants/TransportName' ;
1
2
import initialiseXHRPollingTransport from './xhrpollingtransport' ;
2
3
import initialiseXHRStreamingTransport from './xhrstreamingtransport' ;
3
4
4
- export default [ initialiseXHRPollingTransport , initialiseXHRStreamingTransport ] ;
5
+ export default {
6
+ order : [ TransportName . XhrPolling , TransportName . XhrStreaming ] ,
7
+ implementations : {
8
+ [ TransportName . XhrPolling ] : initialiseXHRPollingTransport ,
9
+ [ TransportName . XhrStreaming ] : initialiseXHRStreamingTransport ,
10
+ } ,
11
+ } ;
You can’t perform that action at this time.
0 commit comments