summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authordor <dor1_b@walla.com>2013-11-22 21:21:56 +0200
committerdor <dor1_b@walla.com>2013-11-22 21:21:56 +0200
commitda24032cbe128d0fa57a652c683fe6715def4071 (patch)
tree92911c3e7c648b53330466c94f9f9028ded4c53a /src
parentcd6f63a1bfed0edb246947a50a6c30d623d8916b (diff)
Start documenting.
Diffstat (limited to 'src')
-rw-r--r--src/Server/Client.java7
-rw-r--r--src/Server/CommandsTable.java17
2 files changed, 21 insertions, 3 deletions
diff --git a/src/Server/Client.java b/src/Server/Client.java
index 6b1bc3a..f577ba6 100644
--- a/src/Server/Client.java
+++ b/src/Server/Client.java
@@ -26,6 +26,11 @@ public class Client
this.nick = newNick;
}
+ public String getHostname()
+ {
+ return "me";
+ }
+
public String getUsername()
{
return this.username;
@@ -50,6 +55,8 @@ public class Client
}
+ /** prints a line to the client socket
+ * @param line the text to print */
public void println(String line) throws IOException
{
output.write(line, 0, line.length());
diff --git a/src/Server/CommandsTable.java b/src/Server/CommandsTable.java
index 93949a8..ce016ed 100644
--- a/src/Server/CommandsTable.java
+++ b/src/Server/CommandsTable.java
@@ -12,6 +12,7 @@ public class CommandsTable
this.table.put("USER", new CommandUser());
this.table.put("QUIT", new CommandQuit());
this.table.put("JOIN", new CommandJoin());
+ this.table.put("PING", new CommandPing());
this.table.put("PRIVMSG", new CommandPrivmsg());
}
@@ -38,7 +39,7 @@ abstract class Command
public void println(Client client, String str)
{
try {
- client.println(":me " + str);
+ client.println(":" + client.getHostname() +" " + str);
} catch (IOException e) {
System.err.println("Failed to print to client socket: <" + str + "> (" + e + ")");
}
@@ -47,7 +48,7 @@ abstract class Command
public void printUser(Client client, String str)
{
try {
- client.println(":" + client.getNick() + "!bla@me " + str);
+ client.println(":" + client.getNick() + "!" + client.getUsername() + "@" + client.getHostname() + str);
} catch (IOException e) {
System.err.println("Failed to print to client socket: <" + str + "> (" + e + ")");
}
@@ -91,7 +92,7 @@ class CommandJoin extends Command
public void run(Client client, String args)
{
- // FIXME: parse args to channel names and save client state
+ // FIXME : parse args to channel names and save client state
// but right now everybody is on a single channel
this.printUser(client, "JOIN " + ":" + args);
this.println(client, "332 " + client.getNick() + " " + args + " :Welcome to the single channel");
@@ -129,3 +130,13 @@ class CommandBad extends Command
}
}
+class CommandPing extends Command
+{
+ public CommandPing() {}
+
+ public void run(Client client, String args)
+ {
+ this.println(client , "PONG " + args + " :" + client.getHostname()); //FIXME: needed massge return
+
+ }
+} \ No newline at end of file