|
|
@ -239,101 +239,6 @@ public class Server extends ServiceManager implements MessageListener { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Send a TCP message to the given connector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param connector The connector to send the message to. |
|
|
|
|
|
|
|
* @param object The object to send. |
|
|
|
|
|
|
|
* @throws IOException When a writing error occurs. |
|
|
|
|
|
|
|
* @deprecated Unnecessary, use client.send(). |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void sendTCP(Client connector, Object object) throws IOException { |
|
|
|
|
|
|
|
if (tcp == null) throw new IOException("No TCP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
tcp.sendObject(connector, object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Send a UDP message to the given connector. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param connector The connector to send to. |
|
|
|
|
|
|
|
* @param object The object to send. |
|
|
|
|
|
|
|
* @throws IOException When a writing error occurs. |
|
|
|
|
|
|
|
* @deprecated Unnecessary, use client.send(). |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void sendUDP(Client connector, Object object) throws IOException { |
|
|
|
|
|
|
|
if (udp == null) throw new IOException("No UDP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
udp.sendObject(connector, object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Broadcast a TCP message. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param object The message to broadcast. |
|
|
|
|
|
|
|
* @throws IOException When a writing error occurs. |
|
|
|
|
|
|
|
* @deprecated Use broadcast() instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void broadcastTCP(Object object) throws IOException { |
|
|
|
|
|
|
|
if (tcp == null) throw new IOException("No TCP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
tcp.sendObject(object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Broadcast a UDP message. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param object The message to broadcast. |
|
|
|
|
|
|
|
* @throws IOException When there's no UDP server initialized, when the server was not bound to a port yet or when a |
|
|
|
|
|
|
|
* write error occurs. |
|
|
|
|
|
|
|
* @deprecated Use broadcast() instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void broadcastUDP(Object object) throws IOException { |
|
|
|
|
|
|
|
if (udp == null) throw new IOException("No UDP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
udp.sendObject(object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Broadcast a message over TCP, except to the given client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param except The client to refrain from sending the object to. |
|
|
|
|
|
|
|
* @param object The object to send. |
|
|
|
|
|
|
|
* @throws IOException When a writing error occurs. |
|
|
|
|
|
|
|
* @deprecated Use broadcastExcept() instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void broadcastExceptTCP(Client except, Object object) throws IOException { |
|
|
|
|
|
|
|
if (tcp == null) throw new IOException("No TCP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
for (Client con : tcp.getConnectors()) { |
|
|
|
|
|
|
|
if (con == except) continue; |
|
|
|
|
|
|
|
con.sendTCP(object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Broadcast a message over UDP, except to the given client. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param except The client to refrain from sending the object to. |
|
|
|
|
|
|
|
* @param object The object to send. |
|
|
|
|
|
|
|
* @throws IOException When a writing error occurs. |
|
|
|
|
|
|
|
* @deprecated Use broadcastExcept() instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void broadcastExceptUDP(Client except, Object object) throws IOException { |
|
|
|
|
|
|
|
if (udp == null) throw new IOException("No UDP server."); |
|
|
|
|
|
|
|
if (!isBound) throw new IOException("Not bound yet. Use bind() first."); |
|
|
|
|
|
|
|
for (Client con : udp.getConnectors()) { |
|
|
|
|
|
|
|
if (con == except) continue; |
|
|
|
|
|
|
|
con.sendUDP(object); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Start this server. |
|
|
|
* Start this server. |
|
|
|
* |
|
|
|
* |
|
|
@ -518,64 +423,6 @@ public class Server extends ServiceManager implements MessageListener { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
///
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Add a message listener for a specific class. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param messageClass The class to listen for. |
|
|
|
|
|
|
|
* @param listener The listener. |
|
|
|
|
|
|
|
* @deprecated Use addMessageListener(MessageListener, Class...) instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void addIndividualMessageListener(Class messageClass, MessageListener listener) { |
|
|
|
|
|
|
|
if (tcp != null) tcp.addIndividualMessageListener(messageClass, listener); |
|
|
|
|
|
|
|
if (udp != null) udp.addIndividualMessageListener(messageClass, listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Add a message listener for specific classes. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param messageClass The classes to listen for. |
|
|
|
|
|
|
|
* @param listener The listener. |
|
|
|
|
|
|
|
* @deprecated Use addMessageListener(MessageListener, Class...) instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void addIndividualMessageListener(Class[] messageClass, MessageListener listener) { |
|
|
|
|
|
|
|
for (Class c : messageClass) { |
|
|
|
|
|
|
|
if (tcp != null) tcp.addIndividualMessageListener(c, listener); |
|
|
|
|
|
|
|
if (udp != null) udp.addIndividualMessageListener(c, listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Remove a message listener for a specific class. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param messageClass The class to what this listener is registered. |
|
|
|
|
|
|
|
* @param listener The listener. |
|
|
|
|
|
|
|
* @deprecated Use removeMessageListener(MessageListener, Class...) instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void removeIndividualMessageListener(Class messageClass, MessageListener listener) { |
|
|
|
|
|
|
|
if (tcp != null) tcp.removeIndividualMessageListener(messageClass, listener); |
|
|
|
|
|
|
|
if (udp != null) udp.removeIndividualMessageListener(messageClass, listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
*Remove a message listener for specific classes. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param messageClass The classes to remove for. |
|
|
|
|
|
|
|
* @param listener The listener. |
|
|
|
|
|
|
|
* @deprecated Use addMessageListener(MessageListener, Class...) instead. |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Deprecated |
|
|
|
|
|
|
|
public void removeIndividualMessageListener(Class[] messageClass, MessageListener listener) { |
|
|
|
|
|
|
|
for (Class c : messageClass) { |
|
|
|
|
|
|
|
if (tcp != null) tcp.removeIndividualMessageListener(c, listener); |
|
|
|
|
|
|
|
if (udp != null) udp.removeIndividualMessageListener(c, listener); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void messageReceived(Message message) { |
|
|
|
public void messageReceived(Message message) { |
|
|
|
// Right now, this is definitely a DisconnectMessage.
|
|
|
|
// Right now, this is definitely a DisconnectMessage.
|
|
|
|
DisconnectMessage dcMessage = (DisconnectMessage)message; |
|
|
|
DisconnectMessage dcMessage = (DisconnectMessage)message; |
|
|
|