summaryrefslogtreecommitdiff
path: root/src/Server/ChatServer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/Server/ChatServer.java')
-rw-r--r--src/Server/ChatServer.java36
1 files changed, 4 insertions, 32 deletions
diff --git a/src/Server/ChatServer.java b/src/Server/ChatServer.java
index b475500..a3d300a 100644
--- a/src/Server/ChatServer.java
+++ b/src/Server/ChatServer.java
@@ -1,5 +1,4 @@
package Server;
-import java.util.*;
import java.net.*;
import java.io.*;
@@ -8,20 +7,10 @@ public class ChatServer
//private static Scanner reader = new Scanner(System.in);
public static final int portNum = 6667;
- private static String[] parseLine(String line)
- {
- String[] parsedLine = line.split("[ \t]+", 2);
- return parsedLine;
-
- }
-
- @SuppressWarnings("deprecation")
public static void main(String[] args) throws IOException
{
- String line;
ServerSocket Service;
- CommandsTable commandsTable = new CommandsTable();
-
+
try
{
Service = new ServerSocket(portNum);
@@ -34,32 +23,15 @@ public class ChatServer
Socket soc = null;
try
{
- Client client;
-
- soc = Service.accept();
- DataInputStream input = new DataInputStream(soc.getInputStream());
- OutputStreamWriter outTemp = new OutputStreamWriter(soc.getOutputStream());
- BufferedWriter output = new BufferedWriter(outTemp);
- client = new Client(soc, output);
-
while (true)
{
- String[] parsedLine;
-
- line = input.readLine(); // FIXME: more then 1 line
- parsedLine = parseLine(line);
- commandsTable.runCommand(client, parsedLine[0], parsedLine[1]);
- line = "<" + line + ">, command: <" + parsedLine[0] + ">, args: <" + parsedLine[1] + ">.";
- System.out.println(line);
-
- // System.out.println("Done");
+ soc = Service.accept();
+ Connection con = new Connection(soc);
+ con.start();
}
} catch (IOException e)
{
- if (soc != null)
- soc.close();
System.out.println(e);
- Service.close();
}
}