Fixed Server Thread Crash $2

This commit is contained in:
brausjonas
2023-02-01 20:41:50 +01:00
parent 4157107813
commit e0ebddd140
8 changed files with 36 additions and 22 deletions
+1
View File
@@ -113,6 +113,7 @@
<workItem from="1675011774462" duration="1723000" /> <workItem from="1675011774462" duration="1723000" />
<workItem from="1675112930043" duration="1858000" /> <workItem from="1675112930043" duration="1858000" />
<workItem from="1675193746966" duration="5298000" /> <workItem from="1675193746966" duration="5298000" />
<workItem from="1675280447181" duration="22000" />
</task> </task>
<servers /> <servers />
</component> </component>
@@ -9,10 +9,10 @@ EditorUserSettings:
value: 5604555501510a0955590d74437008441216412e7578276829704a6bb0b66c3a value: 5604555501510a0955590d74437008441216412e7578276829704a6bb0b66c3a
flags: 0 flags: 0
RecentlyUsedSceneGuid-1: RecentlyUsedSceneGuid-1:
value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a
flags: 0 flags: 0
RecentlyUsedSceneGuid-2: RecentlyUsedSceneGuid-2:
value: 5a5757560101590a5d0c0e24427b5d44434e4c7a7b7a23677f2b4565b7b5353a value: 0000025f04075d0f0c0a5c7149205a4417154f782e7923357e7a4560e3b4653b
flags: 0 flags: 0
UnityRemoteDevice: UnityRemoteDevice:
value: 225f4d46245b0d4902070862342649191512 value: 225f4d46245b0d4902070862342649191512
+1
View File
@@ -79,6 +79,7 @@
<workItem from="1675011672827" duration="777000" /> <workItem from="1675011672827" duration="777000" />
<workItem from="1675111963945" duration="610000" /> <workItem from="1675111963945" duration="610000" />
<workItem from="1675193290788" duration="3495000" /> <workItem from="1675193290788" duration="3495000" />
<workItem from="1675279163903" duration="1178000" />
</task> </task>
<servers /> <servers />
</component> </component>
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+18 -6
View File
@@ -60,8 +60,7 @@ public class Room
players[p].output.write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0}); players[p].output.write(new byte[]{126, 0, 0, 0, 0, 0, 0, 0, 0, 0});
} }
} }
} } catch (Exception e)
catch(Exception e)
{ {
} }
@@ -75,7 +74,9 @@ public class Room
}; };
t.scheduleAtFixedRate(tt, 0, 10000); t.scheduleAtFixedRate(tt, 0, 10000);
}catch(Exception e){} } catch (Exception e)
{
}
} }
public void addClient(Client client) public void addClient(Client client)
@@ -156,9 +157,6 @@ public class Room
players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0}); players[i].output.write(new byte[]{2, (byte) currentPlayer, 0, 0, 0, 0, 0, 0, 0, 0});
} }
break; break;
case 0:
server.deleteRoom(roomCode);
break;
case 126: case 126:
players[player].lastTimeSendTimeOutCheck = System.currentTimeMillis(); players[player].lastTimeSendTimeOutCheck = System.currentTimeMillis();
break; break;
@@ -171,6 +169,7 @@ public class Room
} }
} }
}); });
t.setName("Thread Player: " + (playerCount - 1));
t.start(); t.start();
threads.add(t); threads.add(t);
break; break;
@@ -295,9 +294,22 @@ public class Room
{ {
} }
for (int i = 0; i < threads.size(); i++) for (int i = 0; i < threads.size(); i++)
{
try
{ {
threads.get(i).interrupt(); threads.get(i).interrupt();
} catch (Exception e)
{
}
}
try
{
t.cancel();
} catch (Exception e)
{
} }
} }
} }