Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion code/simplechat1/ClientConsole.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,13 @@ public static void main(String[] args)
{
host = "localhost";
}
ClientConsole chat= new ClientConsole(host, DEFAULT_PORT);
try{
port = Integer.parseInt(args[1]);
}
catch(Exception e){
port = DEFAULT_PORT;
}
ClientConsole chat= new ClientConsole(host, port);
chat.accept(); //Wait for console data
}
}
Expand Down
12 changes: 12 additions & 0 deletions code/simplechat1/EchoServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ protected void serverStopped()
System.out.println
("Server has stopped listening for connections.");
}

protected void clientConnected(ConnectionToClient client){
System.out.println("Client connected to server.");
}

synchronized protected void clientDisconnected(ConnectionToClient client) {
System.out.println("Client disconnected from server.");
}

synchronized protected void clientException(ConnectionToClient client, Throwable exception) {
System.out.println("Client disconnected from server.");
}

//Class methods ***************************************************

Expand Down
11 changes: 11 additions & 0 deletions code/simplechat1/client/ChatClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,17 @@ public void handleMessageFromClientUI(String message)
quit();
}
}

protected void connectionClosed(){
System.out.println("Disconnecting and quitting!");
}

protected void connectionException(Exception e){
if(e instanceof IOException){
System.out.println("The server shut down!");
quit();
}
}

/**
* This method terminates the client.
Expand Down