File tree Expand file tree Collapse file tree 2 files changed +17
-9
lines changed
Expand file tree Collapse file tree 2 files changed +17
-9
lines changed Original file line number Diff line number Diff line change 11{
22 "name" : " speed-testjs" ,
3- "version" : " 1.0.28 " ,
3+ "version" : " 1.0.29 " ,
44 "description" : " measure internet bandwidth" ,
55 "main" : " index.js" ,
66 "author" : " Maulan Byron" ,
Original file line number Diff line number Diff line change 3838 * Initiate the request
3939 */
4040 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+
4852 }
4953 } ;
5054
96100 * close webSocket
97101 */
98102 webSocket . prototype . close = function ( ) {
99- this . _request . close ( ) ;
103+ try {
104+ this . _request . close ( ) ;
105+ } catch ( error ) { // jshint ignore:line
106+
107+ }
100108 } ;
101109
102110
You can’t perform that action at this time.
0 commit comments