-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatServer.java
More file actions
56 lines (49 loc) · 1.42 KB
/
Copy pathChatServer.java
File metadata and controls
56 lines (49 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
package archimedesServer;
import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.*;
import java.util.logging.*;
import java.nio.*;
import java.nio.channels.*;
//import gui.*;
public class ChatServer{
public final static int LOGIN_PORT = 10000;
public final static int NEW_CONVERSATION_PORT = 10001;
private final static Logger _logger = Logger.getLogger("Errors");
private static Vector<Conversation> _conversations;
//private Thread _loginTask;
//private Thread _newConversationTask;
ChatServer(){
// Initialize fixed-port socket.
_conversations = new Vector<Conversation>();
}
public void start(){
Thread loginTask = new MainLoginThread();
loginTask.start();
Thread newConversationTask = new MainNewConversationThread(_conversations);
newConversationTask.start();
Thread storageTask = new MainStorageThread();
storageTask.start();
}
public static void main(String[] argv){
ChatServer chatServer = new ChatServer();
chatServer.start();
Conversation lobby = new Conversation(true, 0, 3333);
Thread t = new Thread(lobby);
t.start();
//System.out.println(c.getPort());
_conversations.addElement(lobby);
char ch;
try{
while( (ch = (char) System.in.read()) != 's')
System.out.println(ch);
} catch(IOException ex){
ex.printStackTrace();
}
System.out.println("stop");
lobby.stopThread();
int p = _conversations.size();
System.out.println("lol"+p);
}
}