summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDor Bivas <dor1_b@walla.com>2013-12-01 13:55:29 +0200
committerDor Bivas <dor1_b@walla.com>2013-12-01 13:55:29 +0200
commitc7876de55daeb34fb7f997aedcd30ce2b36c400d (patch)
treed5b66abc9b6827553afcd6855f5883114b51edf4 /src
parentad5ae2ef8bc7a37050e79b20358334e6a52d6d68 (diff)
Note all the project and task 1-4
Diffstat (limited to 'src')
-rw-r--r--src/Client/ChatClient.java6
-rw-r--r--src/Client/ChatClientReader.java5
-rw-r--r--src/Client/ChatClientWriter.java5
-rw-r--r--src/Client/UserInterface.java (renamed from src/Client/SwingTest.java)45
-rw-r--r--src/Server/ChatServer.java2
-rw-r--r--src/Server/Client.java3
-rw-r--r--src/Server/CommandsTable.java10
7 files changed, 61 insertions, 15 deletions
diff --git a/src/Client/ChatClient.java b/src/Client/ChatClient.java
index f8b3a55..bed7ee1 100644
--- a/src/Client/ChatClient.java
+++ b/src/Client/ChatClient.java
@@ -39,6 +39,8 @@ public class ChatClient
ChatClient client = new ChatClient();
client.setNick("dor");
client.setRealname("Dor bivas");
+
+ UserInterface graphic = new UserInterface();
try
{
@@ -51,9 +53,11 @@ public class ChatClient
ChatClientReader reader = new ChatClientReader(soc);
ChatClientWriter writer = new ChatClientWriter(soc,client);
-
+
+ graphic.show();
reader.start();
writer.start();
+ new UserInterface();
//soc.close();
}
diff --git a/src/Client/ChatClientReader.java b/src/Client/ChatClientReader.java
index 64f92a0..a8c02cb 100644
--- a/src/Client/ChatClientReader.java
+++ b/src/Client/ChatClientReader.java
@@ -8,13 +8,14 @@ public class ChatClientReader extends Thread
public static Scanner reader = new Scanner(System.in);
private Socket soc;
-
-
+ /** constructor
+ * @param the socket */
public ChatClientReader (Socket soc)
{
this.soc = soc;
}
+ /** Running the object and translate the input from bytes to letters*/
public void run()
{
try
diff --git a/src/Client/ChatClientWriter.java b/src/Client/ChatClientWriter.java
index 76ff03d..378008f 100644
--- a/src/Client/ChatClientWriter.java
+++ b/src/Client/ChatClientWriter.java
@@ -11,12 +11,16 @@ public class ChatClientWriter extends Thread
public static Scanner reader = new Scanner(System.in);
+ /** constructor
+ * @param the socket and the client info */
public ChatClientWriter(Socket soc ,ChatClient client)
{
this.soc = soc;
this.client = client;
}
+ /** writing the line and making sure the package will be pushed on the stream
+ * @param the line and the client info */
public void println(String line)
{
try
@@ -29,6 +33,7 @@ public class ChatClientWriter extends Thread
}
+ /** Running the object and translate the output from bytes to letters*/
public void run()
{
try
diff --git a/src/Client/SwingTest.java b/src/Client/UserInterface.java
index bd7d2b4..1bf659e 100644
--- a/src/Client/SwingTest.java
+++ b/src/Client/UserInterface.java
@@ -12,22 +12,25 @@ import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.xml.soap.Text;
-public class SwingTest extends JFrame implements ActionListener
+public class UserInterface extends JFrame implements ActionListener
{
private JTextField message;
private JTextArea output;
+
+ /** Running graphic interface */
public static void main(String args[])
{
- new SwingTest();
+ new UserInterface();
}
-
- SwingTest()
+
+ /** Graphic interface recipient the client*/
+ public UserInterface()
{
this.setIconImage(getIconImage());
this.setSize(800, 400);
output = new JTextArea(10, 20);
- output.setBackground(Color.blue);
+ output.setBackground(Color.gray);
JPanel msgPanel = new JPanel();
JPanel conPanel = new JPanel();
@@ -37,15 +40,21 @@ public class SwingTest extends JFrame implements ActionListener
JButton stop = new JButton("Stop");
stop.setActionCommand("stop");
stop.addActionListener(this);
- stop.setToolTipText("Click this button to exit");
+ stop.setToolTipText("Click this button to exit.");
JButton send = new JButton("Send");
send.setActionCommand("send");
send.addActionListener(this);
- send.setToolTipText("Click this button to send message");
+ send.setToolTipText("Click this button to send message.");
+
+ JButton connect = new JButton("Connect");
+ connect.setActionCommand("connect");
+ connect.addActionListener(this);
+ connect.setToolTipText("Click this button to connect the server.");
vertPanel.setLayout(new BoxLayout(vertPanel, BoxLayout.PAGE_AXIS));
+ msgPanel.add(connect);
msgPanel.add(send);
msgPanel.add(new JLabel("Message:"));
msgPanel.add(message);
@@ -65,8 +74,12 @@ public class SwingTest extends JFrame implements ActionListener
setVisible(true);
}
+ /** Syncing the the action that the button send to the perform
+ * @param name of the action */
+ int counterClick = 0;
public void actionPerformed(ActionEvent e)
{
+
System.out.println(e.getActionCommand()); //FIXME: delete.
String command = e.getActionCommand();
@@ -81,5 +94,23 @@ public class SwingTest extends JFrame implements ActionListener
output.append(message.getText() + "\n");
message.setText("");
}
+
+ if (counterClick>0 && command == "connect")
+ {
+ output.append("You've connected to the server alredy" + "\n");
+ }
+
+ if (command == "connect" && counterClick == 0 )
+ {
+ output.append("You've connect to the server succesufully" + "\n");
+ counterClick++;
+ }
+
+
+
+// public void run ()
+// {
+//
+// }
}
}
diff --git a/src/Server/ChatServer.java b/src/Server/ChatServer.java
index 9e94794..e2d98f4 100644
--- a/src/Server/ChatServer.java
+++ b/src/Server/ChatServer.java
@@ -14,7 +14,7 @@ public class ChatServer
this.service = new ServerSocket(portNum);
this.connections = new LinkedList<Connection>();
}
-
+ /** Listening to port and opening a socket */
public static void main(String[] args) throws IOException
{
ChatServer server;
diff --git a/src/Server/Client.java b/src/Server/Client.java
index 3003c84..34941cb 100644
--- a/src/Server/Client.java
+++ b/src/Server/Client.java
@@ -53,8 +53,7 @@ public class Client
}
}
-
-
+
/** prints a line to the client socket
* @param line the text to print */
public void println(String line) throws IOException
diff --git a/src/Server/CommandsTable.java b/src/Server/CommandsTable.java
index 1ac5a35..2d580fc 100644
--- a/src/Server/CommandsTable.java
+++ b/src/Server/CommandsTable.java
@@ -54,6 +54,7 @@ abstract class Command
}
}
+ /** Remove the first char from the input (this char is irelevant)*/
public static String RemoveFirst(String st)
{
return st.substring(1 , st.length());
@@ -61,7 +62,7 @@ abstract class Command
}
-
+//FIXME:
class CommandPrivmsg extends Command
{
public CommandPrivmsg(){}
@@ -73,7 +74,7 @@ class CommandPrivmsg extends Command
}
}
-
+/** Command that setting the nick name of the client*/
class CommandNick extends Command
{
public CommandNick() {}
@@ -86,6 +87,7 @@ class CommandNick extends Command
}
}
+/** Command that connecting the client to the server */
class CommandJoin extends Command
{
public CommandJoin() {}
@@ -100,6 +102,7 @@ class CommandJoin extends Command
}
}
+/** Command that recipient the client to the irc*/
class CommandUser extends Command
{
public void run(Client client, String args)
@@ -111,6 +114,7 @@ class CommandUser extends Command
}
}
+/** Command that disconnect the client from the server*/
class CommandQuit extends Command
{
public CommandQuit() {}
@@ -122,6 +126,7 @@ class CommandQuit extends Command
}
}
+/**Input of unknown command*/
class CommandBad extends Command
{
public void run(Client client, String args)
@@ -130,6 +135,7 @@ class CommandBad extends Command
}
}
+/** Pinging each few seconds to keep the connection alive*/
class CommandPing extends Command
{
public CommandPing() {}