WIP: Implemented a temporary workaround to send an instance test to client server upon connection.

Still needs reengineering to change socket channels for sending to ouput stream in the message class.
Only client to server "working".

#story[1047] #pair[hyi25, wmu16] #pair[cir27, zyt10]
This commit is contained in:
Haoming Yin
2017-07-17 17:00:04 +12:00
parent 4b8ac32ca9
commit 63958a6717
12 changed files with 154 additions and 68 deletions
@@ -13,13 +13,13 @@ import java.nio.channels.WritableByteChannel;
import java.util.ArrayList;
import java.util.List;
class StreamingServerSocket {
public class StreamingServerSocket {
private ServerSocketChannel socket;
private SocketChannel client;
private short seqNum;
private boolean isServerStarted;
StreamingServerSocket(int port) throws IOException{
public StreamingServerSocket(int port) throws IOException{
socket = ServerSocketChannel.open();
socket.socket().bind(new InetSocketAddress("localhost", port));
//socket.setSoTimeout(10000);
@@ -27,7 +27,7 @@ class StreamingServerSocket {
isServerStarted = false;
}
void start(){
public void start(){
try {
client = socket.accept();
} catch (IOException e) {
@@ -41,7 +41,7 @@ class StreamingServerSocket {
}
}
void send(Message message) throws IOException{
public void send(Message message) throws IOException{
if (client == null){
return;