Added functionality for more than one visualiser to connect to the mock.
- more than one visualiser can now connect to the mock. - Created class ConnectionAcceptor that will accept and allocate to each socket - Issue of sockets connecting after the race starts then disconnecting will use a socket slot. #story[1010]
This commit is contained in:
@@ -75,6 +75,7 @@ public class ConnectionController extends Controller {
|
||||
try{
|
||||
RaceConnection connection = connectionTable.getSelectionModel().getSelectedItem();
|
||||
Socket socket = new Socket(connection.getHostname(), connection.getPort());
|
||||
socket.setKeepAlive(true);
|
||||
connectionWrapper.setVisible(false);
|
||||
parent.enterLobby(socket);
|
||||
} catch (IOException e) { /* Never reached */ }
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.nio.ByteBuffer;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
|
||||
import static network.Utils.ByteConverter.bytesToShort;
|
||||
|
||||
@@ -372,6 +373,4 @@ public class VisualiserInput implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -33,6 +33,10 @@ public class RaceConnection {
|
||||
try (Socket s = new Socket()){
|
||||
s.connect(i, 750);//TODO this should be at least a second or two, once moved to its own thread
|
||||
status.set("Ready");
|
||||
s.shutdownInput();
|
||||
s.shutdownOutput();
|
||||
s.close();
|
||||
System.out.println(String.valueOf(s.isClosed()));
|
||||
return true;
|
||||
} catch (IOException e) {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user