You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
System.out.println( "This example shows how to send fragmented(continuous) messages.\n It also shows that fragments can be intercepted by normal messages." );
31
+
System.out.println( "This example shows how to send fragmented(continuous) messages." );
System.out.println( "The long message you just typed in will be fragmented in messages of 2bytes payload each.\nPress enter so send the next fragemnt or make some other input to send text messages inbetween." );
40
40
for( intposition = 2 ; ; position += 2 ) {
41
-
42
-
StringsendInOnePiece = stdin.readLine();
43
-
if( !sendInOnePiece.isEmpty() ) {
44
-
websocket.send( sendInOnePiece );
45
-
}
46
-
47
41
if( position < longelinebuffer.capacity() ) {
48
42
longelinebuffer.limit( position );
49
-
websocket.sendFragmentedFrame( Opcode.TEXT, longelinebuffer, false );// when sending binary data use Opcode.BINARY
43
+
websocket.sendFragmentedFrame( Opcode.TEXT, longelinebuffer, false );// when sending binary data one should use Opcode.BINARY
44
+
assert ( longelinebuffer.remaining() == 0 );
45
+
// after calling sendFragmentedFrame one may reuse the buffer given to the method immediately
0 commit comments