package com.lary.chatroom;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.ServerSocket;
import java.net.Socket;
import java.util.Collection;
import java.util.Date;
import java.util.Hashtable;
import java.util.Map;
import java.util.Set;
public class ChatRoomServer {
private ServerSocket ss;
private Map onlineUsers;
public ChatRoomServer(){
try {
ss=new ServerSocket(8090);
onlineUsers=new Hashtable();
} catch (IOException e) {
e.printStackTrace();
}
}
public void startService(){
Socket s=null;
try {
while (true) {
s = ss.accept();
new ChatRoomServerThread(s).start();
}
} catch (IOException e) {
e.printStackTrace();
}
}
class ChatRoomServerThread extends Thread{
private Socket s;
private BufferedReader br;
private PrintWriter pw;
public ChatRoomServerThread(Socket s){
this.s=s;
try {
br=new BufferedReader(new InputStreamReader(s.getInputStream()));
pw=new PrintWriter(s.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
1