Even better server resource management
This commit is contained in:
Generated
+1
-1
@@ -92,7 +92,7 @@
|
|||||||
<workItem from="1677881295823" duration="3489000" />
|
<workItem from="1677881295823" duration="3489000" />
|
||||||
<workItem from="1680022478274" duration="3769000" />
|
<workItem from="1680022478274" duration="3769000" />
|
||||||
<workItem from="1680215686971" duration="1247000" />
|
<workItem from="1680215686971" duration="1247000" />
|
||||||
<workItem from="1680262711476" duration="2830000" />
|
<workItem from="1680262711476" duration="3955000" />
|
||||||
</task>
|
</task>
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -31,12 +31,9 @@ public class Room
|
|||||||
//tells players turn (array index)
|
//tells players turn (array index)
|
||||||
private int currentPlayer = 0;
|
private int currentPlayer = 0;
|
||||||
|
|
||||||
private long timeOut = 0;
|
|
||||||
private Timer t;
|
|
||||||
|
|
||||||
public Room(String roomCode, Server server)
|
public Room(String roomCode, Server server)
|
||||||
{
|
{
|
||||||
timeOut = System.currentTimeMillis();
|
|
||||||
|
|
||||||
this.roomCode = roomCode;
|
this.roomCode = roomCode;
|
||||||
startPositions = new Vector3[4];
|
startPositions = new Vector3[4];
|
||||||
@@ -56,8 +53,6 @@ public class Room
|
|||||||
*/
|
*/
|
||||||
public void addClient(Client client)
|
public void addClient(Client client)
|
||||||
{
|
{
|
||||||
//the timeout variable for a single player
|
|
||||||
timeOut = System.currentTimeMillis();
|
|
||||||
|
|
||||||
//loops through all players existing and sends the needed information
|
//loops through all players existing and sends the needed information
|
||||||
for (int i = 0; i < players.length; i++)
|
for (int i = 0; i < players.length; i++)
|
||||||
@@ -100,9 +95,6 @@ public class Room
|
|||||||
//read the data to the buffer
|
//read the data to the buffer
|
||||||
input.read(readData);
|
input.read(readData);
|
||||||
|
|
||||||
//reset the timeout once something is received
|
|
||||||
timeOut = System.currentTimeMillis();
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
@@ -407,12 +399,5 @@ public class Room
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
t.cancel();
|
|
||||||
} catch (Exception e)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,7 +52,8 @@ public class Server
|
|||||||
System.out.println("Client connected!");
|
System.out.println("Client connected!");
|
||||||
|
|
||||||
//create a new thread for the connected client to free up main thread resources for new connections
|
//create a new thread for the connected client to free up main thread resources for new connections
|
||||||
Thread t = new Thread(new Runnable()
|
Thread t = null;
|
||||||
|
t = new Thread(new Runnable()
|
||||||
{
|
{
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
@@ -81,6 +82,9 @@ public class Server
|
|||||||
/**
|
/**
|
||||||
* !!!!!!!!!!!!!!!!!!! 0 is not used because of possible empty arrays read in because of inital connection errors !!!!!!!!!!!!!!!!!!!!
|
* !!!!!!!!!!!!!!!!!!! 0 is not used because of possible empty arrays read in because of inital connection errors !!!!!!!!!!!!!!!!!!!!
|
||||||
*/
|
*/
|
||||||
|
case 0:
|
||||||
|
Integer.parseInt("crash");
|
||||||
|
break;
|
||||||
|
|
||||||
//this case generates a new room and sends the room code to the requester (not for join)
|
//this case generates a new room and sends the room code to the requester (not for join)
|
||||||
case 2:
|
case 2:
|
||||||
@@ -139,6 +143,8 @@ public class Server
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
System.out.println("Init Thread finished");
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e)
|
||||||
{
|
{
|
||||||
System.out.println("Client disconnected!");
|
System.out.println("Client disconnected!");
|
||||||
|
|||||||
Reference in New Issue
Block a user