Implemented list views initialisation which will set the first pane to be your source id (after three way handshake) and the remaining pane to be the source id of other players based on boats.xml received.

Updated client parser and client state to save a list of player's boat

WIP: refresh list view to show the latest update in players

#story[1055]
This commit is contained in:
Zhi You Tan
2017-07-23 20:42:21 +12:00
parent e11ceed28c
commit 9d754c8819
7 changed files with 180 additions and 58 deletions
@@ -32,14 +32,15 @@ public class ClientToServerThread implements Runnable {
private ByteArrayOutputStream crcBuffer;
public ClientToServerThread(String ipAddress, Integer portNumber) throws Exception{
socket = new Socket(ipAddress, portNumber);
is = socket.getInputStream();
os = socket.getOutputStream();
socket = new Socket(ipAddress, portNumber);
is = socket.getInputStream();
os = socket.getOutputStream();
Integer allocatedID = threeWayHandshake();
if (allocatedID != null) {
ourID = allocatedID;
clientLog("Successful handshake. Allocated ID: " + ourID, 1);
ClientState.setClientSourceId(String.valueOf(ourID));
} else {
clientLog("Unsuccessful handhsake", 1);
closeSocket();
@@ -96,13 +97,17 @@ public class ClientToServerThread implements Runnable {
} else {
System.err.println("Packet has been dropped");
}
}
} catch (Exception e) {
closeSocket();
System.out.println("this exception");
return;
}
}
closeSocket();
System.out.println("[CLIENT] Disconnected from server");
}