Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- class SvrMsgHndlr { //Server Message Handler
- private static String Logg="-----------------------------\n";
- public boolean sndUnPwd(String un,String pwd) { //Fucntion to send user info to the ncs for authorization
- return true;
- }
- public boolean rcvAuth() { //This function recives true and returns it if the user is authenticated
- return true;
- }
- public String getTheLog() { //This function fetches last 30 lines for the server log
- //Logg="\n---------------------------\nsubin:What the fuck?\nnapster:Nothing dude\nsubin:ok\n"; //temp data
- return Logg;
- }
- public boolean updtTheLog(String lc) { //Updating the log //TODO add a send msg procedre
- Logg+=lc+"\n";
- return true;
- }
- }
- class NetChatClient {
- static DataInputStream x; //Input stream for normal reading in
- private static String uname;
- private static String passwd;
- private static String Fullchat; //It is the full string that should be displayed, include local chat and nessessory formatting
- private static String LocalChat; //Local user's message
- private static SvrMsgHndlr H; //All the server side things will be done
- public static void readUnamePasswd()
- throws IOException { //Function for reading username and password
- System.out.print("Enter your username : "); //Asks the user for username
- uname=x.readLine(); //Moves the Username to the variable 'uname'
- System.out.print("Enter your password : "); //Asks for password
- passwd=x.readLine(); //Moves the Password to the variable 'passwd'
- }
- public static String getLocalMsg() //Wait for the user Message
- throws IOException { //Handled exception
- x=new DataInputStream(System.in); //Reads the user's message
- return x.readLine(); //Gives back the user input
- }
- public static void main(String args[]) //Main class
- throws IOException { //program starts
- x=new DataInputStream(System.in); //Initializing x
- H=new SvrMsgHndlr(); //Initializing H
- readUnamePasswd();
- H.sndUnPwd(uname,passwd); //Send the packet to ncs
- while(H.rcvAuth()) { //While the user is authenticated
- LocalChat=uname+":"+getLocalMsg(); //Get user input
- H.updtTheLog(LocalChat); //Appending local chat
- System.out.print(H.getTheLog()); //Getting and printing the full chat
- System.out.print("---------------------------------------------\n"+uname+":"); //Just for user interface
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement