Skip to content

Commit

Permalink
completed
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 b9935cd commit 041853d
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 50 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.
36 changes: 14 additions & 22 deletions GUI/src/chat/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,32 +27,14 @@ public class Client extends javax.swing.JFrame {
static Socket clientSocket=null;
static Client obj;
static Receive2 receiver;
static Send2 sender;
static DataOutputStream dos;
boolean b=true;
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=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}
msg.setText("");
dos.close();
}

catch(Exception e){}
}
}
class Receive2 extends Thread{
synchronized public void run(){
public void run(){
try{
BufferedReader br=null;
try{
Expand Down Expand Up @@ -138,8 +120,17 @@ 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();
try{
String str=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}
msg.setText("");
}

catch(Exception e){}
}//GEN-LAST:event_jButton1ActionPerformed

/**
Expand All @@ -150,6 +141,7 @@ public static void main(String args[]) throws Exception{
obj.setVisible(true);
clientSocket=new Socket(InetAddress.getLocalHost(),99);

dos=new DataOutputStream(clientSocket.getOutputStream());
receiver=obj.new Receive2();
receiver.start();
}
Expand Down
48 changes: 20 additions & 28 deletions GUI/src/chat/Server.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ public class Server extends javax.swing.JFrame {
static Socket client=null;
static Server obj;
static Receive1 receiver;
static Send1 sender;
static DataOutputStream dos;
public Server() {
super("first");
initComponents();
}
boolean b=true;
class Receive1 extends Thread{
synchronized public void run(){
public void run(){
try{
BufferedReader br=null;
try{
Expand All @@ -58,30 +58,6 @@ synchronized public void run(){
catch(IOException e){}
}
}
class Send1 extends Thread{
synchronized public void run(){
try{
OutputStream os=client.getOutputStream();
DataOutputStream dos=new DataOutputStream(os);
/*BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(!(str=br.readLine()).equalsIgnoreCase("quit")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}*/
String str=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}

msg.setText("");
dos.close();
}
catch(Exception e){}
}
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
Expand Down Expand Up @@ -146,8 +122,23 @@ 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();
try{
/*BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
while(!(str=br.readLine()).equalsIgnoreCase("quit")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}*/
String str=msg.getText();
if(!str.equals("")){
dos.write(str.getBytes());
dos.write(13);
dos.flush();
}

msg.setText("");
}
catch(Exception e){}
}//GEN-LAST:event_jButton1ActionPerformed

/**
Expand All @@ -170,6 +161,7 @@ public static void main(String args[]) throws Exception{
client=serverSocket.accept();
receiver=obj.new Receive1();

dos=new DataOutputStream(client.getOutputStream());
receiver.start();
}

Expand Down

0 comments on commit 041853d

Please sign in to comment.