Class ServerConnection
- java.lang.Object
-
- org.activecomponents.udp.holepunching.server.ServerConnection
-
- All Implemented Interfaces:
java.lang.Runnable
,IConnectedHost
,IRegisteredHost
public class ServerConnection extends java.lang.Object implements java.lang.Runnable, IConnectedHost, IRegisteredHost
-
-
Field Summary
Fields Modifier and Type Field Description protected java.net.Socket
cmdsocket
Socket that receives commands from the client.static java.util.List<java.lang.String>
COMMAND_CLASSNAMES
static java.util.List<java.lang.String>
COMMAND_CLASSNAMES_WEB
protected IServerCommand[]
commands
protected java.net.DatagramSocket
dgsocket
protected byte[]
readbuffer
protected java.lang.String
registered
protected java.util.Map<java.lang.String,IRegisteredHost>
registeredhosts
protected boolean
running
protected static java.lang.String
WELCOME_MSG
-
Constructor Summary
Constructors Constructor Description ServerConnection(java.net.Socket cmdsocket, java.net.DatagramSocket dgsocket, java.util.Map<java.lang.String,IRegisteredHost> registeredhosts)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static IServerCommand[]
getCommands(java.util.List<java.lang.String> classnames, java.lang.ClassLoader cl)
java.lang.String
getRegistered()
java.util.Map<java.lang.String,IRegisteredHost>
getRegisteredHosts()
Retrieves the registered hosts.java.net.InetAddress
getRemoteAddress()
Gets the address of the connected host.java.net.DatagramSocket
getUdpSocket()
Retrieves the UDP socket for testing communication.protected java.lang.String
readNextLine()
void
run()
protected java.lang.String
runCommand(java.lang.String cmd, java.lang.String[] args)
void
setRegistered(java.lang.String registered)
void
writeMsg(java.lang.String msg)
Writes a message to the connected host.
-
-
-
Field Detail
-
WELCOME_MSG
protected static final java.lang.String WELCOME_MSG
- See Also:
- Constant Field Values
-
COMMAND_CLASSNAMES
public static final java.util.List<java.lang.String> COMMAND_CLASSNAMES
-
COMMAND_CLASSNAMES_WEB
public static final java.util.List<java.lang.String> COMMAND_CLASSNAMES_WEB
-
cmdsocket
protected java.net.Socket cmdsocket
Socket that receives commands from the client.
-
dgsocket
protected java.net.DatagramSocket dgsocket
-
registeredhosts
protected java.util.Map<java.lang.String,IRegisteredHost> registeredhosts
-
commands
protected IServerCommand[] commands
-
readbuffer
protected byte[] readbuffer
-
running
protected boolean running
-
registered
protected volatile java.lang.String registered
-
-
Constructor Detail
-
ServerConnection
public ServerConnection(java.net.Socket cmdsocket, java.net.DatagramSocket dgsocket, java.util.Map<java.lang.String,IRegisteredHost> registeredhosts)
-
-
Method Detail
-
run
public void run()
- Specified by:
run
in interfacejava.lang.Runnable
-
writeMsg
public void writeMsg(java.lang.String msg)
Writes a message to the connected host.- Specified by:
writeMsg
in interfaceIRegisteredHost
- Parameters:
msg
- The message.
-
getRemoteAddress
public java.net.InetAddress getRemoteAddress()
Gets the address of the connected host.- Specified by:
getRemoteAddress
in interfaceIConnectedHost
- Returns:
- The address.
-
getUdpSocket
public java.net.DatagramSocket getUdpSocket()
Retrieves the UDP socket for testing communication.- Specified by:
getUdpSocket
in interfaceIConnectedHost
- Returns:
- The UDP socket.
-
getRegisteredHosts
public java.util.Map<java.lang.String,IRegisteredHost> getRegisteredHosts()
Retrieves the registered hosts.- Specified by:
getRegisteredHosts
in interfaceIConnectedHost
- Returns:
- The registered hosts.
-
getRegistered
public java.lang.String getRegistered()
-
setRegistered
public void setRegistered(java.lang.String registered)
-
runCommand
protected java.lang.String runCommand(java.lang.String cmd, java.lang.String[] args)
-
readNextLine
protected java.lang.String readNextLine() throws java.lang.Exception
- Throws:
java.lang.Exception
-
getCommands
public static IServerCommand[] getCommands(java.util.List<java.lang.String> classnames, java.lang.ClassLoader cl)
-
-