@@ -90,56 +90,64 @@ public void run() {
9090 // read packetId
9191 final int packetId = readingByteBuffer .readInt ();
9292 // check if packet is UpdateUUIDPacket
93- if (packetId == -2 ) {
94- // read connectionUUID
95- final UUID connectionUUID = readingByteBuffer .readUUID ();
96- // set updated connectionUUID
97- this .client .getConnectionUUID ().set (connectionUUID );
98- this .resetCalculation ();
99- this .receiveIncomingPacketMessage (
100- UpdateUUIDPacket .class .getName (), connectionUUID .toString ());
101- } else if (packetId == -3 ) {
102- // read connectionUUID
103- final UUID connectionUUID = readingByteBuffer .readUUID ();
104- // set updated connectionUUID
105- this .resetCalculation ();
106- this .receiveIncomingPacketMessage (
107- KeepAlivePacket .class .getName (), connectionUUID .toString ());
108- } else if (packetId == -4 ) {
109- final UUID connectionUUID = readingByteBuffer .readUUID ();
110- this .resetCalculation ();
111- this .receiveIncomingPacketMessage (
112- ClientDisconnectPacket .class .getName (), connectionUUID .toString ());
113- SignalCallRegistry .getReferenceCaller ()
114- .getDeclaredConstructor (String .class )
115- .newInstance (this .toString ())
116- .clientFromClientServerSideDisconnection (connectionUUID );
117- } else {
118- // get packet
119- final Class <? extends Packet > packet = PacketRegistry .get (packetId );
120-
121- // check if received packet not null
122- if (packet != null ) {
93+ switch (packetId ) {
94+ case -2 : {
95+ // read connectionUUID
96+ final UUID connectionUUID = readingByteBuffer .readUUID ();
97+ // set updated connectionUUID
98+ this .client .getConnectionUUID ().set (connectionUUID );
99+ this .resetCalculation ();
100+ this .receiveIncomingPacketMessage (
101+ UpdateUUIDPacket .class .getName (), connectionUUID .toString ());
102+ break ;
103+ }
104+ case -3 : {
123105 // read connectionUUID
124106 final UUID connectionUUID = readingByteBuffer .readUUID ();
125- // initialise packet
126- packet
127- .getDeclaredConstructor (UUID .class )
128- .newInstance (connectionUUID )
129- .receive (readingByteBuffer );
130- Cache .setIncomingPackets (Cache .getIncomingPackets () + 1 );
131- this .client .setIncomingPackets (this .client .getIncomingPackets () + 1 );
132- // set cached time to 0;
107+ // set updated connectionUUID
133108 this .resetCalculation ();
134- // SignalProvider.getSignalProvider().setIncomingPackets(SignalProvider.getSignalProvider().getIncomingPackets() + 1);
135- this .receiveIncomingPacketMessage (packet .getName (), connectionUUID .toString ());
136- } else {
109+ this .receiveIncomingPacketMessage (
110+ KeepAlivePacket .class .getName (), connectionUUID .toString ());
111+ break ;
112+ }
113+ case -4 : {
114+ final UUID connectionUUID = readingByteBuffer .readUUID ();
115+ this .resetCalculation ();
116+ this .receiveIncomingPacketMessage (
117+ ClientDisconnectPacket .class .getName (), connectionUUID .toString ());
137118 SignalCallRegistry .getReferenceCaller ()
138119 .getDeclaredConstructor (String .class )
139120 .newInstance (this .toString ())
140- .receivePacketIsNullMessage (
141- SignalProvider . getSignalProvider (). getIncomingPacketIsNull ()) ;
121+ .clientFromClientServerSideDisconnection ( connectionUUID );
122+ break ;
142123 }
124+ default :
125+ // get packet
126+ final Class <? extends Packet > packet = PacketRegistry .get (packetId );
127+
128+ // check if received packet not null
129+ if (packet != null ) {
130+ // read connectionUUID
131+ final UUID connectionUUID = readingByteBuffer .readUUID ();
132+ // initialise packet
133+ packet
134+ .getDeclaredConstructor (UUID .class )
135+ .newInstance (connectionUUID )
136+ .receive (readingByteBuffer );
137+ Cache .setIncomingPackets (Cache .getIncomingPackets () + 1 );
138+ this .client .setIncomingPackets (this .client .getIncomingPackets () + 1 );
139+ // set cached time to 0;
140+ this .resetCalculation ();
141+ // SignalProvider.getSignalProvider().setIncomingPackets(SignalProvider.getSignalProvider().getIncomingPackets() + 1);
142+ this .receiveIncomingPacketMessage (packet .getName (), connectionUUID .toString ());
143+ } else {
144+ SignalCallRegistry .getReferenceCaller ()
145+ .getDeclaredConstructor (String .class )
146+ .newInstance (this .toString ())
147+ .receivePacketIsNullMessage (
148+ SignalProvider .getSignalProvider ().getIncomingPacketIsNull ());
149+ }
150+ break ;
143151 }
144152 } else {
145153 SignalCallRegistry .getReferenceCaller ()
@@ -212,7 +220,7 @@ private void calculateClientTimeoutTime() {
212220 this .cachedTime = System .currentTimeMillis ();
213221 } else {
214222 final long estimatedTime = System .currentTimeMillis () - this .cachedTime ;
215- if (estimatedTime = = this .client .getTimeout ()) {
223+ if (estimatedTime > = this .client .getTimeout ()) {
216224 try {
217225 SignalCallRegistry .getReferenceCaller ()
218226 .getDeclaredConstructor (String .class )
0 commit comments