Can now show client and server versions.

This commit is contained in:
Deathsbreed 2014-05-04 20:18:33 -05:00
parent 000d834d42
commit 9d7612cd55
3 changed files with 12 additions and 2 deletions

View File

@ -47,10 +47,16 @@ public class Client implements Runnable {
} }
public void run() { public void run() {
String uinput;
while(thread != null) { while(thread != null) {
try { try {
streamOut.writeUTF(console.readLine()); uinput = console.readLine();
streamOut.flush(); if(uinput.equals("/clientVersion")) {
System.out.println(version);
} else {
streamOut.writeUTF(uinput);
streamOut.flush();
}
} catch(IOException e) { } catch(IOException e) {
System.out.println("Sending error: " + e.getMessage()); System.out.println("Sending error: " + e.getMessage());
stop(); stop();

View File

@ -92,6 +92,8 @@ public class Server implements Runnable {
if(input.equals("/quit")) { if(input.equals("/quit")) {
clients.get(findClient(id)).send("/quit"); clients.get(findClient(id)).send("/quit");
remove(id); remove(id);
} else if(input.equals("/serverVersion")) {
clients.get(findClient(id)).send(version);
} else if(input.equals("/list")) { } else if(input.equals("/list")) {
int pos = findClient(id); int pos = findClient(id);
for(int i = 0; i < clients.size(); i++) { for(int i = 0; i < clients.size(); i++) {

View File

@ -59,6 +59,8 @@ public class ServerThread extends Thread {
" - /myUserName -- Returns your username.\n" + " - /myUserName -- Returns your username.\n" +
" - /pm [id] [msg] -- Sends a message to only one of the clients.\n" + " - /pm [id] [msg] -- Sends a message to only one of the clients.\n" +
" - /setUserName [newusername] -- Change your username.\n" + " - /setUserName [newusername] -- Change your username.\n" +
" - /clientVersion -- Returns the version of the client.\n" +
" - /serverVersion -- Returns the version of the server.\n" +
" - /help -- Show this information.\n" + " - /help -- Show this information.\n" +
" - /quit -- Quit.\n"); " - /quit -- Quit.\n");
if(admin) { if(admin) {