@@ -347,15 +347,15 @@ public void onOpen() {
347
347
Log .v ("websocket" , "Connected!" );
348
348
appView .post (new Runnable () {
349
349
public void run () {
350
- appView .loadUrl (buildJavaScriptData (EVENT_ON_MESSAGE , BLANK_MESSAGE ));
350
+ appView .loadUrl (buildJavaScriptData (EVENT_ON_OPEN , BLANK_MESSAGE ));
351
351
}
352
352
});
353
353
}
354
354
355
355
public void onClose () {
356
356
appView .post (new Runnable () {
357
357
public void run () {
358
- appView .loadUrl (buildJavaScriptData (EVENT_ON_MESSAGE , BLANK_MESSAGE ));
358
+ appView .loadUrl (buildJavaScriptData (EVENT_ON_CLOSE , BLANK_MESSAGE ));
359
359
}
360
360
});
361
361
}
@@ -366,7 +366,7 @@ public void onError(Throwable t) {
366
366
t .printStackTrace ();
367
367
appView .post (new Runnable () {
368
368
public void run () {
369
- appView .loadUrl (buildJavaScriptData (EVENT_ON_MESSAGE , msg ));
369
+ appView .loadUrl (buildJavaScriptData (EVENT_ON_ERROR , msg ));
370
370
}
371
371
});
372
372
}
@@ -692,8 +692,13 @@ private String _randomKey() {
692
692
key = new StringBuilder (key ).insert (position , randChar ).toString ();
693
693
}
694
694
for (int i = 0 ; i < spaces ; i ++) {
695
- int position = r .nextInt (key .length () - 1 ) + 1 ;
696
- position = Math .abs (position );
695
+ int n = key .length () - 1 ;
696
+ int position ;
697
+ if (n == 0 ) {
698
+ position = 1 ;
699
+ } else {
700
+ position = r .nextInt (n ) + 1 ;
701
+ }
697
702
key = new StringBuilder (key ).insert (position , "\u0020 " ).toString ();
698
703
}
699
704
return key ;
0 commit comments