|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectworkspace.NetworkManager
public class NetworkManager
A NetworkManager maintains connections and host information. The network is peer-to-peer over TCP.
Constructor Summary | |
---|---|
NetworkManager()
|
Method Summary | |
---|---|
(package private) void |
connect(java.net.Socket s)
|
protected void |
disconnect(java.lang.Long id)
Disconnect from the given host, if connected. |
protected void |
disconnected(java.lang.Long id)
Receive notification that we've disconnected from a host. |
static void |
error(java.lang.String msg)
Displays an error message to the user. |
protected boolean |
establishConnection(java.lang.String host,
int port)
Open a client connection. |
protected boolean |
eventReceived(NetworkEvent obj)
Process objects as they are read. |
protected NetworkConnection |
getHost(java.lang.Long host)
Allow subclasses to access the host information. |
static long |
getHostIdentifier(java.net.InetAddress addr,
int port)
Returns the long (8-byte) identifier for the given host. |
java.lang.String |
getServerAddress()
|
long |
getServerHash()
|
int |
getServerPort()
|
boolean |
openServerConnection()
Open a server connection. |
boolean |
sendEvent(java.lang.Long host,
NetworkEvent event)
Send the event to the host. |
void |
sendEvent(NetworkEvent event)
Broadcast the event to all connected parties. |
protected void |
setServerHash(long hash)
Be careful when calling this method. |
void |
stop()
Close all connections and reset the server. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NetworkManager()
Method Detail |
---|
public long getServerHash()
public int getServerPort()
protected void setServerHash(long hash)
public java.lang.String getServerAddress()
protected NetworkConnection getHost(java.lang.Long host)
public void sendEvent(NetworkEvent event)
public boolean sendEvent(java.lang.Long host, NetworkEvent event)
protected boolean establishConnection(java.lang.String host, int port)
public boolean openServerConnection()
protected void disconnect(java.lang.Long id)
public void stop()
void connect(java.net.Socket s) throws java.io.IOException
java.io.IOException
protected boolean eventReceived(NetworkEvent obj)
protected void disconnected(java.lang.Long id)
public static void error(java.lang.String msg)
public static long getHostIdentifier(java.net.InetAddress addr, int port)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |