File tree 2 files changed +17
-9
lines changed
2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 1
1
{
2
2
"name" : " speed-testjs" ,
3
- "version" : " 1.0.28 " ,
3
+ "version" : " 1.0.29 " ,
4
4
"description" : " measure internet bandwidth" ,
5
5
"main" : " index.js" ,
6
6
"author" : " Maulan Byron" ,
Original file line number Diff line number Diff line change 38
38
* Initiate the request
39
39
*/
40
40
webSocket . prototype . start = function ( ) {
41
- if ( this . _request === null ||
42
- typeof this . _request === 'undefined' ) {
43
- this . _request = new WebSocket ( this . url ) ;
44
- this . _request . onopen = this . _handleOnOpen . bind ( this ) ;
45
- this . _request . onmessage = this . _handleOnMessage . bind ( this ) ;
46
- this . _request . onclose = this . _handleOnClose . bind ( this ) ;
47
- this . _request . onerror = this . _handleOnError . bind ( this ) ;
41
+ if ( this . _request === null || typeof this . _request === 'undefined' ) {
42
+ try {
43
+ this . _request = new WebSocket ( this . url ) ;
44
+ this . _request . onopen = this . _handleOnOpen . bind ( this ) ;
45
+ this . _request . onmessage = this . _handleOnMessage . bind ( this ) ;
46
+ this . _request . onclose = this . _handleOnClose . bind ( this ) ;
47
+ this . _request . onerror = this . _handleOnError . bind ( this ) ;
48
+ } catch ( err ) {
49
+ this . callbackOnError ( 'connection error' ) ;
50
+ }
51
+
48
52
}
49
53
} ;
50
54
96
100
* close webSocket
97
101
*/
98
102
webSocket . prototype . close = function ( ) {
99
- this . _request . close ( ) ;
103
+ try {
104
+ this . _request . close ( ) ;
105
+ } catch ( error ) { // jshint ignore:line
106
+
107
+ }
100
108
} ;
101
109
102
110
You can’t perform that action at this time.
0 commit comments