Skip to content

Commit

Permalink
add sv_showusers command option in the console to see the list of cur…
Browse files Browse the repository at this point in the history
…rently online users in the room
  • Loading branch information
iamrohitsuthar committed Aug 9, 2019
1 parent ef70fd2 commit 9ff3b02
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@
/logout(1).png
/logout.png
/logout(2).resized.png
/live.png
18 changes: 16 additions & 2 deletions src/com/chatroom/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import java.lang.Thread.State;
import java.net.Socket;
import java.util.Scanner;

import com.chatroom.configuration.Config;
import com.chatroom.models.Request;
import com.chatroom.models.Response;
Expand Down Expand Up @@ -236,7 +237,20 @@ else if(response.getId() == Response.Type.MSG.ordinal() || response.getId() == R
else
Message.println("\n<" + name + ">: " + msg);
}

else if(response.getId() == Response.Type.GEN.ordinal()) {
String data = "List of Online Users \n";
int i = 1;
data += i + ". You \n";
String temp = response.getContents();
if(temp.length() != 0 && !temp.equals("")) {
String arrayOFNames[] = temp.split(",");
for (String string : arrayOFNames) {
i++;
data += i + ". " + string + "\n";
}
}
Message.println(data);
}
if(response.getContents().equals("sv_exit_successful")) {
synchronized(this){
this.wait();
Expand Down Expand Up @@ -326,4 +340,4 @@ else if(response.getId() == Request.Type.LOGIN.ordinal()) {
LogFileWriter.Log(Config.errors.toString());
}
}
}
}

0 comments on commit 9ff3b02

Please sign in to comment.