diff options
author | Dor Bivas <dor1_b@walla.com> | 2013-12-11 16:27:03 +0200 |
---|---|---|
committer | Dor Bivas <dor1_b@walla.com> | 2013-12-11 16:29:22 +0200 |
commit | c35cc0aa84ba0f17f0aba07e0b1358dc2545d4f1 (patch) | |
tree | ad4624c5ff19fcfeaf9796f7454f3e7d96a33c32 | |
parent | e289f6ea8d3e5e6e548f979890bb0e5593d4b593 (diff) |
client tasks 4-7
-rw-r--r-- | src/Client/UserInterface.java | 37 | ||||
-rw-r--r-- | src/Server/ChatServer.java | 8 |
2 files changed, 40 insertions, 5 deletions
diff --git a/src/Client/UserInterface.java b/src/Client/UserInterface.java index 0580e3b..02abbfd 100644 --- a/src/Client/UserInterface.java +++ b/src/Client/UserInterface.java @@ -2,6 +2,7 @@ package Client; import java.awt.Color; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; +import java.net.Socket; import javax.swing.AbstractButton; import javax.swing.BoxLayout; @@ -9,6 +10,7 @@ import javax.swing.JButton; import javax.swing.JFrame; import javax.swing.JLabel; import javax.swing.JPanel; +import javax.swing.JScrollPane; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.xml.soap.Text; @@ -23,6 +25,7 @@ public class UserInterface extends JFrame implements ActionListener private JTextField host = new JTextField("localhost", 15); private JTextField port = new JTextField("6667", 4); private JButton connect; + private JButton send; public void outputWriter (String line) @@ -46,13 +49,16 @@ public class UserInterface extends JFrame implements ActionListener JPanel conPanel = new JPanel(); JPanel vertPanel = new JPanel(); + JTextArea feedbackText = new JTextArea(); + JScrollPane scrollText = new JScrollPane(feedbackText); + message = new JTextField(40); JButton stop = new JButton("Stop"); stop.setActionCommand("stop"); stop.addActionListener(this); stop.setToolTipText("Click this button to exit."); - JButton send = new JButton("Send"); + this.send = new JButton("Send"); send.setActionCommand("send"); send.addActionListener(this); send.setToolTipText("Click this button to send message."); @@ -61,6 +67,7 @@ public class UserInterface extends JFrame implements ActionListener connect.setActionCommand("connect"); connect.addActionListener(this); connect.setToolTipText("Click this button to connect the server."); + this.send.setEnabled(false); vertPanel.setLayout(new BoxLayout(vertPanel, BoxLayout.PAGE_AXIS)); @@ -75,6 +82,8 @@ public class UserInterface extends JFrame implements ActionListener conPanel.add(new JLabel("port:")); conPanel.add(port); + conPanel.add(scrollText); + vertPanel.add(output); vertPanel.add(conPanel); vertPanel.add(msgPanel); @@ -87,6 +96,7 @@ public class UserInterface extends JFrame implements ActionListener int counterClick = 0; + /** Syncing the the action that the button send to the perform * @param name of the action */ public void actionPerformed(ActionEvent e) @@ -98,8 +108,28 @@ public class UserInterface extends JFrame implements ActionListener { System.exit(0); } - - if (command == "send") + +// if (e.getSource() == 'escape') +// { +// System.exit(0); +// } +// +// if (e.getSource() == 'ALT' + 'F4') +// { +// System.exit(0); +// } +// +// +// if (e.getSource() == 'enter') +// { +// output.append(message.getText() + "\n"); +// client.PRIVMSG(message.getText()); +// message.setText(""); +// } + + + + if (command == "send" ) { output.append(message.getText() + "\n"); client.PRIVMSG(message.getText()); @@ -113,6 +143,7 @@ public class UserInterface extends JFrame implements ActionListener { output.append("You've connect to the server succesufully" + "\n"); counterClick++; + this.send.setEnabled(true); this.connect.setEnabled(false); } } diff --git a/src/Server/ChatServer.java b/src/Server/ChatServer.java index 4a21cfd..0e6e8a8 100644 --- a/src/Server/ChatServer.java +++ b/src/Server/ChatServer.java @@ -49,8 +49,12 @@ public class ChatServer * * * Allow listening on a different port (from command-line?) * * Have a test server running on cohens.org.il - * * Send requests to all channels (use list) - * * When passing a message (PRIVMSG) - inlcude the sender's nick. + * * Send requests to all clients (use list) + * - When a client disconnects - remove it from connections list. + * - temporary: When we get a PRIVMSG, iterate over connections and write message and every client + * - When we get a PRIVMSG, iterate over connections and write the message to each client + * * Don't allow two clients with the same nick + * * When passing a message (PRIVMSG) - include the sender's nick. * * Keep channels up: PING occasionally * * Graphical interface for server */ |