scp-app

git clone git://git.codymlewis.com/scp-app.git
Log | Files | Refs | LICENSE

commit 614bf24cf69d51b5b0df05b7a3b9da037224c2b2
parent cb2c3f554c74d1a0dde4bd1ad709e84c171f86cd
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Fri, 24 Aug 2018 09:57:23 +1000

Minor refinements

Diffstat:
MChat.java | 3+++
MChatServer.java | 6++++--
2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/Chat.java b/Chat.java @@ -27,6 +27,9 @@ public class Chat { scp = new SCP(); console = new Scanner(System.in); } + protected String rules() { + return "Press enter twice to send a message,\nType DISCONNECT to end the chat"; + } /** * Take an input from the users and give an out suitable to put into a message * @return A String of the input formatted to be embedded in a SCP message diff --git a/ChatServer.java b/ChatServer.java @@ -66,11 +66,12 @@ public class ChatServer extends Chat { scpAccept(); if(acknowledged()) { System.out.println(String.format("User %s has connected to SCP", username)); + System.out.println(); messageLoop(); } } } catch(NullPointerException npe) { - System.out.println("\nError: unexpected cutoff from client, looking for new client"); + System.out.println("\nError: unexpected cut-off from client, looking for new client"); } finally { hostConnection(); } @@ -79,9 +80,10 @@ public class ChatServer extends Chat { * Loop for sending a recieving messages */ private void messageLoop() throws SCPException, IOException { - String message = welcomeMessage; + String message = welcomeMessage + "\n" + rules() + "\n"; // send welcome message + chat rules to client String recievedMessage; boolean disconnect = false; + System.out.println(rules()); while(!disconnect) { System.out.println("Waiting for message to send"); out.println(scp.message(address.getHostAddress(), port, message));