1
+ import { DDP , LivedataTest } from "./namespace.js" ;
2
+
1
3
// @param endpoint {String} URL to Meteor app
2
4
// "http://subdomain.meteor.com/" or "/" or
3
5
// "ddp+sockjs://foo-**.meteor.com/sockjs"
9
11
// We don't do any heartbeating. (The logic that did this in sockjs was removed,
10
12
// because it used a built-in sockjs mechanism. We could do it with WebSocket
11
13
// ping frames or with DDP-level messages.)
12
- LivedataTest . ClientStream = function ( endpoint , options ) {
13
- var self = this ;
14
- options = options || { } ;
15
-
16
- self . options = _ . extend ( {
17
- retry : true
18
- } , options ) ;
14
+ LivedataTest . ClientStream = class ClientStream {
15
+ constructor ( endpoint , options ) {
16
+ const self = this ;
17
+ options = options || { } ;
19
18
20
- self . client = null ; // created in _launchConnection
21
- self . endpoint = endpoint ;
19
+ self . options = Object . assign ( {
20
+ retry : true
21
+ } , options ) ;
22
22
23
- self . headers = self . options . headers || { } ;
24
- self . npmFayeOptions = self . options . npmFayeOptions || { } ;
23
+ self . client = null ; // created in _launchConnection
24
+ self . endpoint = endpoint ;
25
25
26
- self . _initCommon ( self . options ) ;
26
+ self . headers = self . options . headers || { } ;
27
+ self . npmFayeOptions = self . options . npmFayeOptions || { } ;
27
28
28
- //// Kickoff!
29
- self . _launchConnection ( ) ;
30
- } ;
29
+ self . _initCommon ( self . options ) ;
31
30
32
- _ . extend ( LivedataTest . ClientStream . prototype , {
31
+ //// Kickoff!
32
+ self . _launchConnection ( ) ;
33
+ }
33
34
34
35
// data is a utf8 string. Data sent while not connected is dropped on
35
36
// the floor, and it is up the user of this API to retransmit lost
36
37
// messages on 'reset'
37
- send : function ( data ) {
38
+ send ( data ) {
38
39
var self = this ;
39
40
if ( self . currentStatus . connected ) {
40
41
self . client . send ( data ) ;
41
42
}
42
- } ,
43
+ }
43
44
44
45
// Changes where this connection points
45
- _changeUrl : function ( url ) {
46
+ _changeUrl ( url ) {
46
47
var self = this ;
47
48
self . endpoint = url ;
48
- } ,
49
+ }
49
50
50
- _onConnect : function ( client ) {
51
+ _onConnect ( client ) {
51
52
var self = this ;
52
53
53
54
if ( client !== self . client ) {
@@ -86,9 +87,9 @@ _.extend(LivedataTest.ClientStream.prototype, {
86
87
// fire resets. This must come after status change so that clients
87
88
// can call send from within a reset callback.
88
89
_ . each ( self . eventCallbacks . reset , function ( callback ) { callback ( ) ; } ) ;
89
- } ,
90
+ }
90
91
91
- _cleanup : function ( maybeError ) {
92
+ _cleanup ( maybeError ) {
92
93
var self = this ;
93
94
94
95
self . _clearConnectionTimer ( ) ;
@@ -101,18 +102,18 @@ _.extend(LivedataTest.ClientStream.prototype, {
101
102
callback ( maybeError ) ;
102
103
} ) ;
103
104
}
104
- } ,
105
+ }
105
106
106
- _clearConnectionTimer : function ( ) {
107
+ _clearConnectionTimer ( ) {
107
108
var self = this ;
108
109
109
110
if ( self . connectionTimer ) {
110
111
clearTimeout ( self . connectionTimer ) ;
111
112
self . connectionTimer = null ;
112
113
}
113
- } ,
114
+ }
114
115
115
- _getProxyUrl : function ( targetUrl ) {
116
+ _getProxyUrl ( targetUrl ) {
116
117
var self = this ;
117
118
// Similar to code in tools/http-helpers.js.
118
119
var proxy = process . env . HTTP_PROXY || process . env . http_proxy || null ;
@@ -121,9 +122,9 @@ _.extend(LivedataTest.ClientStream.prototype, {
121
122
proxy = process . env . HTTPS_PROXY || process . env . https_proxy || proxy ;
122
123
}
123
124
return proxy ;
124
- } ,
125
+ }
125
126
126
- _launchConnection : function ( ) {
127
+ _launchConnection ( ) {
127
128
var self = this ;
128
129
self . _cleanup ( ) ; // cleanup the old socket, if there was one.
129
130
@@ -200,4 +201,4 @@ _.extend(LivedataTest.ClientStream.prototype, {
200
201
} ) ;
201
202
} ) ;
202
203
}
203
- } ) ;
204
+ } ;
0 commit comments