summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDor Bivas <dor1_b@walla.com>2014-02-22 14:10:24 +0200
committerDor Bivas <dor1_b@walla.com>2014-02-22 14:10:24 +0200
commitec570b2a1afdb481703b9114fa9673bb759b8c08 (patch)
treea0227c8d9836958f281872861f4bc3308cd4e9be
parent1c4577ec2824f9e4c9d678132a0d05065cfaca9c (diff)
ChatClient : Starting with Dor-Chet Channel
-rw-r--r--src/Client/ChatClient.java24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/Client/ChatClient.java b/src/Client/ChatClient.java
index b29c756..6d22d58 100644
--- a/src/Client/ChatClient.java
+++ b/src/Client/ChatClient.java
@@ -22,6 +22,8 @@ public class ChatClient
private Socket soc;
private boolean isConnected = false;
+ private static final String CHANNEL = "#Dor-chat"; //FIXME: should be public. But it's interesting if the server could be ignorant of it
+
ChatClient() {
this.soc = null;
}
@@ -54,6 +56,11 @@ public class ChatClient
this.isConnected = true;
}
+ public boolean getConnected()
+ {
+ return this.isConnected;
+ }
+
/** send a line to server */
public void runSendline (String line)
{
@@ -73,10 +80,25 @@ public class ChatClient
else
{
- runSendline("PRIVMSG " + "#Chat-Dor :" + line);
+ runSendline("PRIVMSG " + this.CHANNEL + " :" + line);
}
}
+ public void fixNickCollision()
+ {
+ String newNick = getNick() + new Integer((int) (Math.random()*1000)).toString();
+ runSendline("NICK " + newNick);
+ }
+
+ /** Initial setup with the server once the nick was set up*/
+ public void startup()
+ {
+ // 0: mode (nothing special). *: unused in RFC 2812, server name in RFC 1459
+ runSendline("USER " + this.getNick() + " 0 * :" + this.getRealname());
+ runSendline("JOIN " + this.CHANNEL);
+ this.setConnected(); // FIXME: Not sure yet if client is connected.
+ }
+
public void shutdown()
{
if (soc != null)