summaryrefslogtreecommitdiff
path: root/src/Client/ChatClient.java
diff options
context:
space:
mode:
authorTzafrir Cohen <tzafrir@cohens.org.il>2013-12-04 10:50:36 +0200
committerTzafrir Cohen <tzafrir@cohens.org.il>2013-12-04 10:50:36 +0200
commit3bbbd95c8d2d6f3185b0f3e48263f36ba4bb0e75 (patch)
treeb336db15d08ab911658a646a6b7f3e6bf011be28 /src/Client/ChatClient.java
parentd57f9416a9d4bb92d4111f73af278f607bbe78b9 (diff)
Convert source to NL-terminated
Diffstat (limited to 'src/Client/ChatClient.java')
-rw-r--r--src/Client/ChatClient.java220
1 files changed, 110 insertions, 110 deletions
diff --git a/src/Client/ChatClient.java b/src/Client/ChatClient.java
index a1727e9..a3807f2 100644
--- a/src/Client/ChatClient.java
+++ b/src/Client/ChatClient.java
@@ -1,110 +1,110 @@
-package Client;
-import java.io.*;
-import java.net.Socket;
-
-
-
-import Server.ChatServer;
-
-public class ChatClient
-{
- String nick;
- String realname;
- BufferedWriter output;
- UserInterface ui;
-
- /** returning the nick name */
- public String getNick ()
- {
- return this.nick;
- }
- /** returning the real name */
- public String getRealname ()
- {
- return this.realname;
- }
- /** changing the nick name */
- public void setNick (String nick)
- {
- this.nick = nick;
- }
- /** changing the real name */
- public void setRealname (String realname)
- {
- this.realname = realname;
- }
-
- public boolean connect (String host, int port)
- {
- Socket soc;
- ChatClient client = new ChatClient();
-
- try
- {
- soc = new Socket(host, port);
- ChatClientReader reader = new ChatClientReader(soc);
-
- reader.setDisplay(client.ui);
-
- ChatClientWriter writer = new ChatClientWriter(soc,client);
-
- reader.start();
- writer.start();
-
- return true;
-
- } catch (IOException e)
- {
- System.err.println("Failed connecting to server: " + host + ":" + port + " (" + e + ")");
- return false;
- }
- }
-
- public static void main(String[] args) throws IOException
- {
- ChatClient client = new ChatClient();
- client.setNick("dor");
- client.setRealname("Dor bivas");
- client.ui = new UserInterface(client);
-
-
-
- //soc.close();
- }
-
-}
-
-
-
-/** Tasks
- * TODO: 1. Data received from the network will be written to the output window.
- *
- * TODO: 2. When the user presses "Connect", a message will be sent to a channel:
- * use PRIVMSG to channel #chat.
- *
- * TODO: 3. But we do want to allow sending commands to the channel. A
- * message line that begins with the word "/QUOTE", will be sent as is
- * (except the word "/QUOTE") to the server.
- *
- * TODO: 4. Join a channel at startup: For any server besides our own we need to send
- * a JOIN command (see how it is handled in the server).
- *
- * TODO: 5. Don't allow sending text until we joined a channel.
- *
- * TODO: 6. When we get from the server a PRIVMSG, parse it and show who sent it.
- * Print other messages (Server messages) differently.
- */
-
-/** Later
- *
- * * Fix or remove all the fixme-s.
- * * Closing the program (Close, ALT-F4) does not end the process
- * * The output buffer does not have a scroll bar.
- * * Pressing Enter in the message line does not send text.
- * * It may be handy to implement other client commands:
- * - /NICK - changes the nick
- * - /CLEAR - clears the output window
- * - /SAY - print a message directly to output window
- * - // - sends just a leading '/' (in case you want to send '/NICK whatever' to the channel
- * - /HELP - print a help message to the user
- */
+package Client;
+import java.io.*;
+import java.net.Socket;
+
+
+
+import Server.ChatServer;
+
+public class ChatClient
+{
+ String nick;
+ String realname;
+ BufferedWriter output;
+ UserInterface ui;
+
+ /** returning the nick name */
+ public String getNick ()
+ {
+ return this.nick;
+ }
+ /** returning the real name */
+ public String getRealname ()
+ {
+ return this.realname;
+ }
+ /** changing the nick name */
+ public void setNick (String nick)
+ {
+ this.nick = nick;
+ }
+ /** changing the real name */
+ public void setRealname (String realname)
+ {
+ this.realname = realname;
+ }
+
+ public boolean connect (String host, int port)
+ {
+ Socket soc;
+ ChatClient client = new ChatClient();
+
+ try
+ {
+ soc = new Socket(host, port);
+ ChatClientReader reader = new ChatClientReader(soc);
+
+ reader.setDisplay(client.ui);
+
+ ChatClientWriter writer = new ChatClientWriter(soc,client);
+
+ reader.start();
+ writer.start();
+
+ return true;
+
+ } catch (IOException e)
+ {
+ System.err.println("Failed connecting to server: " + host + ":" + port + " (" + e + ")");
+ return false;
+ }
+ }
+
+ public static void main(String[] args) throws IOException
+ {
+ ChatClient client = new ChatClient();
+ client.setNick("dor");
+ client.setRealname("Dor bivas");
+ client.ui = new UserInterface(client);
+
+
+
+ //soc.close();
+ }
+
+}
+
+
+
+/** Tasks
+ * TODO: 1. Data received from the network will be written to the output window.
+ *
+ * TODO: 2. When the user presses "Connect", a message will be sent to a channel:
+ * use PRIVMSG to channel #chat.
+ *
+ * TODO: 3. But we do want to allow sending commands to the channel. A
+ * message line that begins with the word "/QUOTE", will be sent as is
+ * (except the word "/QUOTE") to the server.
+ *
+ * TODO: 4. Join a channel at startup: For any server besides our own we need to send
+ * a JOIN command (see how it is handled in the server).
+ *
+ * TODO: 5. Don't allow sending text until we joined a channel.
+ *
+ * TODO: 6. When we get from the server a PRIVMSG, parse it and show who sent it.
+ * Print other messages (Server messages) differently.
+ */
+
+/** Later
+ *
+ * * Fix or remove all the fixme-s.
+ * * Closing the program (Close, ALT-F4) does not end the process
+ * * The output buffer does not have a scroll bar.
+ * * Pressing Enter in the message line does not send text.
+ * * It may be handy to implement other client commands:
+ * - /NICK - changes the nick
+ * - /CLEAR - clears the output window
+ * - /SAY - print a message directly to output window
+ * - // - sends just a leading '/' (in case you want to send '/NICK whatever' to the channel
+ * - /HELP - print a help message to the user
+ */