File tree Expand file tree Collapse file tree 2 files changed +7
-4
lines changed
src/de/javasocketapi/core Expand file tree Collapse file tree 2 files changed +7
-4
lines changed Original file line number Diff line number Diff line change 77import java .util .Timer ;
88import java .util .TimerTask ;
99import java .util .UUID ;
10+ import java .util .concurrent .atomic .AtomicReference ;
1011
1112class InputStreamThread {
1213
@@ -31,7 +32,7 @@ public void run() {
3132 } catch (final IOException e ) {
3233 e .printStackTrace ();
3334 }
34- final byte [][] bytes = new byte [ 1 ][ 1 ] ;
35+ final AtomicReference < byte []> bytes = new AtomicReference <>( null ) ;
3536 //start reading byte arrays
3637 final InputStream finalInputStream = inputStream ;
3738 this .timer .scheduleAtFixedRate (new TimerTask () {
@@ -48,12 +49,13 @@ public void run() {
4849 if (finalInputStream .available () > 0 ) {
4950 final int b = finalInputStream .read ();
5051 if (b != -1 ) {
51- bytes [ 0 ] = new byte [b ];
52+ bytes . set ( new byte [b ]) ;
5253 //receive bytes
53- finalInputStream .read (bytes [ 0 ] , 0 , b );
54- final ReadingByteBuffer readingByteBuffer = new ReadingByteBuffer (bytes [ 0 ] );
54+ finalInputStream .read (bytes . get () , 0 , b );
55+ final ReadingByteBuffer readingByteBuffer = new ReadingByteBuffer (bytes . get () );
5556 //read packetId
5657 final int packetId = readingByteBuffer .readInt ();
58+
5759 //check if packet is UpdateUUIDPacket
5860 if (packetId == -2 ) {
5961 //read connectionUUID
Original file line number Diff line number Diff line change 11package de .javasocketapi .core ;
22
3+
34import java .nio .ByteBuffer ;
45import java .nio .charset .StandardCharsets ;
56import java .util .UUID ;
You can’t perform that action at this time.
0 commit comments