diff options
| author | O'Shea <osheas1@wit.edu> | 2020-12-10 14:03:54 -0500 |
|---|---|---|
| committer | O'Shea <osheas1@wit.edu> | 2020-12-10 14:03:54 -0500 |
| commit | cca61c9f562d2c9e2be13ec16abe134d209b54e3 (patch) | |
| tree | 3f957b579c45d0536e7e1740acdb0cdbc773f9f4 /src/javaChat/ClientGUI.java | |
| parent | 690bbba9550e2644e48db44fb94d4df86494a34e (diff) | |
Final implementation, ready for presentation!
Diffstat (limited to 'src/javaChat/ClientGUI.java')
| -rw-r--r-- | src/javaChat/ClientGUI.java | 97 |
1 files changed, 0 insertions, 97 deletions
diff --git a/src/javaChat/ClientGUI.java b/src/javaChat/ClientGUI.java deleted file mode 100644 index 3b98486..0000000 --- a/src/javaChat/ClientGUI.java +++ /dev/null @@ -1,97 +0,0 @@ -package javaChat; - -import java.net.* ; -import java.io.* ; - -/** - * - * - * @author osheas1 - * @version 1.0.0 2020-12-07 Initial implementation - * - */ -public class ClientGUI - { - - public static void main( String[] args ) throws IOException - { - - UserInterface login = new UserInterface() ; - login.setVisible( true ); - - boolean done = false ; - while( !done ) - { - done = login.isDone() ; - System.out.print(""); - } - - String ip = login.getIP() ; - String username = login.getUsername() ; - - // Open your connection to a server, at port 6789 - Socket socket = new Socket( ip , 6789 ) ; - - // Create communication streams - DataInputStream dataStreamIn = new DataInputStream( socket.getInputStream() ) ; - DataOutputStream dataStreamOut = new DataOutputStream( socket.getOutputStream() ) ; - - BufferedReader keyboard = new BufferedReader( new InputStreamReader( System.in ) ) ; - - dataStreamOut.writeUTF( username ) ; - - // Thread for sending messages - Thread sendMessage = new Thread(new Runnable() - { - @Override - public void run() - { - System.out.print( "\n-= Type /help for a list of commands =-" ) ; - while( true ) - { - try - { - String messageOut = keyboard.readLine() ; - dataStreamOut.writeUTF( messageOut ) ; - } - catch( IOException x ) - { - x.printStackTrace() ; - System.exit( 0 ) ; - } - } - } - }) ; - - // Thread for receiving messages - Thread receiveMessage = new Thread( new Runnable() - { - - @Override - public void run() - { - while( true ) - { - try - { - String messageIn = dataStreamIn.readUTF() ; - System.out.printf( "%n%s\n", messageIn ) ; - } - catch( IOException x ) - { - x.printStackTrace() ; - System.exit( 0 ) ; - } - } - } - }); - - // Begin threads - sendMessage.start() ; - receiveMessage.start() ; - - - } - - } - // end class ClientGUI
\ No newline at end of file |
