Kick All Players on Player leave
This commit is contained in:
+40
-18
@@ -106,15 +106,6 @@ public class Room
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
players[player].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
server.deleteRoom(roomCode);
|
||||
for(int i = 0; i < threads.size(); i++)
|
||||
{
|
||||
@@ -125,15 +116,7 @@ public class Room
|
||||
|
||||
} catch (IOException e)
|
||||
{
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < players.length; i++)
|
||||
{
|
||||
players[player].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
}
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
|
||||
for(int i = 0; i < threads.size(); i++)
|
||||
{
|
||||
threads.get(i).stop();
|
||||
@@ -197,4 +180,43 @@ public class Room
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void closeRoom()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
players[0].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
players[1].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
players[2].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
players[3].output.write(new byte[]{127, 0, 0, 0, 0, 0, 0, 0, 0, 0});
|
||||
|
||||
} catch (IOException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ public class Server
|
||||
|
||||
public void deleteRoom(String code)
|
||||
{
|
||||
rooms.get(code).closeRoom();
|
||||
rooms.remove(code);
|
||||
System.out.println("Room " + code + " successfully deleted");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user