Advertisement
Guest User

Untitled

a guest
May 1st, 2017
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. class SvrMsgHndlr { //Server Message Handler
  4. private static String Logg="-----------------------------\n";
  5. public boolean sndUnPwd(String un,String pwd) { //Fucntion to send user info to the ncs for authorization
  6. return true;
  7. }
  8. public boolean rcvAuth() { //This function recives true and returns it if the user is authenticated
  9. return true;
  10. }
  11. public String getTheLog() { //This function fetches last 30 lines for the server log
  12. //Logg="\n---------------------------\nsubin:What the fuck?\nnapster:Nothing dude\nsubin:ok\n"; //temp data
  13. return Logg;
  14. }
  15. public boolean updtTheLog(String lc) { //Updating the log //TODO add a send msg procedre
  16. Logg+=lc+"\n";
  17. return true;
  18. }
  19. }
  20.  
  21. class NetChatClient {
  22. static DataInputStream x; //Input stream for normal reading in
  23. private static String uname;
  24. private static String passwd;
  25. private static String Fullchat; //It is the full string that should be displayed, include local chat and nessessory formatting
  26. private static String LocalChat; //Local user's message
  27. private static SvrMsgHndlr H; //All the server side things will be done
  28.  
  29. public static void readUnamePasswd()
  30. throws IOException { //Function for reading username and password
  31. System.out.print("Enter your username : "); //Asks the user for username
  32. uname=x.readLine(); //Moves the Username to the variable 'uname'
  33. System.out.print("Enter your password : "); //Asks for password
  34. passwd=x.readLine(); //Moves the Password to the variable 'passwd'
  35. }
  36. public static String getLocalMsg() //Wait for the user Message
  37. throws IOException { //Handled exception
  38. x=new DataInputStream(System.in); //Reads the user's message
  39. return x.readLine(); //Gives back the user input
  40. }
  41. public static void main(String args[]) //Main class
  42. throws IOException { //program starts
  43. x=new DataInputStream(System.in); //Initializing x
  44. H=new SvrMsgHndlr(); //Initializing H
  45. readUnamePasswd();
  46. H.sndUnPwd(uname,passwd); //Send the packet to ncs
  47. while(H.rcvAuth()) { //While the user is authenticated
  48. LocalChat=uname+":"+getLocalMsg(); //Get user input
  49. H.updtTheLog(LocalChat); //Appending local chat
  50. System.out.print(H.getTheLog()); //Getting and printing the full chat
  51. System.out.print("---------------------------------------------\n"+uname+":"); //Just for user interface
  52. }
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement