scp-app

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

commit e93e3d5f2f88e21353695f0987fbdaabf8365d9c
parent f88bf68bb19cfe4aa214c3e7317ca212e9e91138
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Mon,  3 Sep 2018 08:07:52 +1000

Fixed username bug

Diffstat:
MChat.java | 4++--
MChatClient.java | 1+
MChatServer.java | 1+
3 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/Chat.java b/Chat.java @@ -30,6 +30,7 @@ public class Chat extends JFrame { protected InetAddress address; protected int port; protected String username; + protected String otherUsername; public static final long serialVersionUID = 1L; protected JTextArea msgArea; protected JTextField msgField; @@ -149,8 +150,7 @@ public class Chat extends JFrame { * Loop for sending a recieving messages */ protected void messageLoop() throws SCPException, IOException { - String uname = username == null ? "Client" : "Server"; // a server has null username - recvMsg = new Thread(new Recieve(uname), "scp"); + recvMsg = new Thread(new Recieve(otherUsername), "scp"); recvMsg.start(); } /** diff --git a/ChatClient.java b/ChatClient.java @@ -39,6 +39,7 @@ public class ChatClient extends Chat { msgArea.append("Exchanging keys with the server\n"); keyExchange(); username = args.length > 2 ? args[2] : "Client"; + otherUsername = "Server"; SCPConnect(); msgArea.append("Connected to SCP\n"); while(!disconnect) { diff --git a/ChatServer.java b/ChatServer.java @@ -70,6 +70,7 @@ public class ChatServer extends Chat { msgArea.append("Waiting for client to SCP connect\n"); username = clientConnect(); username = username.substring(1, username.length() - 1); // remove quotes + otherUsername = username; if(username == "") { // Can't have a blank username anyway cliSocket.close(); msgArea.append("Rejected client for time differential greater than 5, trying again");