Server upgrades, getting ready to store user data and process opcodes
git-svn-id: svn://anubis/gvsu@35 45c1a28c-8058-47b2-ae61-ca45b979098e
This commit is contained in:
parent
b977f19565
commit
dd1e73971d
@ -7,6 +7,7 @@ public class KaZaServer implements Runnable
|
||||
{
|
||||
public static final int LISTEN_PORT = 3442;
|
||||
private ServerSocket m_serverSocket;
|
||||
private HashMap<String, ClientInfo> m_clientData;
|
||||
|
||||
public void run()
|
||||
{
|
||||
@ -32,17 +33,65 @@ public class KaZaServer implements Runnable
|
||||
{
|
||||
}
|
||||
|
||||
public String[] getClientList()
|
||||
{
|
||||
Set<String> s;
|
||||
synchronized (m_clientData)
|
||||
{
|
||||
s = m_clientData.keySet();
|
||||
}
|
||||
return (String[]) s.toArray();
|
||||
}
|
||||
|
||||
private class ClientInfo
|
||||
{
|
||||
String userName;
|
||||
}
|
||||
|
||||
private class ClientHandler implements Runnable
|
||||
{
|
||||
Socket m_socket;
|
||||
private Socket m_socket;
|
||||
private String m_clientIP;
|
||||
|
||||
public ClientHandler(Socket socket)
|
||||
{
|
||||
m_socket = socket;
|
||||
m_clientIP = m_socket.getInetAddress().getHostAddress();
|
||||
synchronized (m_clientData)
|
||||
{
|
||||
if (!m_clientData.containsKey(m_clientIP))
|
||||
{
|
||||
m_clientData.put(socket.getInetAddress().getHostAddress(),
|
||||
new ClientInfo());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader br = new BufferedReader(
|
||||
new InputStreamReader(
|
||||
m_socket.getInputStream()));
|
||||
|
||||
/* loop processing client messages */
|
||||
for (;;)
|
||||
{
|
||||
String inLine = br.readLine();
|
||||
|
||||
StringTokenizer tokens = new StringTokenizer(inLine);
|
||||
if (!tokens.hasMoreTokens())
|
||||
continue;
|
||||
|
||||
String opCode = tokens.nextToken();
|
||||
opCode.toLowerCase();
|
||||
if (opCode.equals("HELO"))
|
||||
{
|
||||
/* user is announcing his or her username */
|
||||
}
|
||||
}
|
||||
} catch (Exception e) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user