Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanay Toshniwal authored and Tanay Toshniwal committed Dec 29, 2017
1 parent 84d1637 commit 2582517
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 24 deletions.
Binary file modified GUI/build/classes/chat/Client$1.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Client$Receive2.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Client$Send2.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Client.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Server$1.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Server$Receive1.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Server$Send1.class
Binary file not shown.
Binary file modified GUI/build/classes/chat/Server.class
Binary file not shown.
25 changes: 10 additions & 15 deletions GUI/src/chat/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,30 +29,24 @@ public class Client extends javax.swing.JFrame {
static Receive2 receiver;
static Send2 sender;
public Client() {
super("second");
initComponents();
}
class Send2 extends Thread{
synchronized public void run(){
try{
OutputStream os=clientSocket.getOutputStream();
DataOutputStream dos=new DataOutputStream(os);
String str="";
System.out.println("Connection Established.");
/*BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(!(str=br.readLine()).equalsIgnoreCase("quit")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}*/
str=msg.getText();
while(!str.equals("")){
String str=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}
msg.setText("");
dos.close();
}
catch(IOException e){System.exit(0);}
catch(Exception e){}
}
}
class Receive2 extends Thread{
Expand All @@ -71,10 +65,11 @@ synchronized public void run(){
String str="";
while((str=br.readLine())!=null){
area.append(str);
area.append("\n");
}
br.close();
}
catch(IOException e){System.exit(0);}
catch(IOException e){}
}
}
/**
Expand Down Expand Up @@ -141,18 +136,18 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
sender=obj.new Send2();

sender.start();
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) throws IOException{
public static void main(String args[]) throws Exception{
obj=new Client();
obj.setVisible(true);
clientSocket=new Socket(InetAddress.getLocalHost(),99);

sender=obj.new Send2();
receiver=obj.new Receive2();
receiver.start();
}
Expand Down
20 changes: 11 additions & 9 deletions GUI/src/chat/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ public class Server extends javax.swing.JFrame {
static Receive1 receiver;
static Send1 sender;
public Server() {
super("first");
initComponents();
}
class Receive1 extends Thread{
Expand All @@ -49,34 +50,35 @@ synchronized public void run(){
String str="";
while((str=br.readLine())!=null){
area.append(str);
area.append("\n");
}
br.close();
}
catch(IOException e){System.exit(0);}
catch(IOException e){}
}
}
class Send1 extends Thread{
synchronized public void run(){
try{
OutputStream os=client.getOutputStream();
DataOutputStream dos=new DataOutputStream(os);
String str="";
System.out.println("Connection Established.");
/*BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(!(str=br.readLine()).equalsIgnoreCase("quit")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}*/
str=msg.getText();
while(!str.equals("")){
String str=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}

msg.setText("");
dos.close();
}
catch(IOException e){System.exit(0);}
catch(Exception e){}
}
}
/**
Expand Down Expand Up @@ -143,14 +145,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) {

private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
sender=obj.new Send1();

sender.start();
}//GEN-LAST:event_jButton1ActionPerformed

/**
* @param args the command line arguments
*/
public static void main(String args[]) throws IOException{
public static void main(String args[]) throws Exception{
obj=new Server();
obj.setVisible(true);
try{
Expand All @@ -165,8 +167,8 @@ public static void main(String args[]) throws IOException{
System.exit(1);
}
client=serverSocket.accept();

receiver=obj.new Receive1();
sender=obj.new Send1();
receiver.start();
}

Expand Down

0 comments on commit 2582517

Please sign in to comment.