Package ucar.nc2.ui.util
Class SocketMessage
- java.lang.Object
-
- ucar.nc2.ui.util.SocketMessage
-
public final class SocketMessage extends Object
Starts up a server socket on the given port, and listens for messages sent to it. Sends the contents of the message to anyone who is registered as a listener.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description class
SocketMessage.Event
static interface
SocketMessage.EventListener
-
Constructor Summary
Constructors Constructor Description SocketMessage(int port, String message)
Try to start a listener on the given port.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addEventListener(SocketMessage.EventListener l)
Add a EventListenerboolean
isAlreadyRunning()
Was the port already in use?void
removeEventListener(SocketMessage.EventListener l)
Remove an EventListener.void
setRaw(boolean raw)
-
-
-
Constructor Detail
-
SocketMessage
public SocketMessage(int port, String message)
Try to start a listener on the given port. If that port is already used, send the given message to it.- Parameters:
port
- listen on this server port.message
- send this message if port in use
-
-
Method Detail
-
setRaw
public void setRaw(boolean raw)
-
isAlreadyRunning
public boolean isAlreadyRunning()
Was the port already in use?- Returns:
- true if the port was already in use
-
addEventListener
public void addEventListener(SocketMessage.EventListener l)
Add a EventListener- Parameters:
l
- the listener
-
removeEventListener
public void removeEventListener(SocketMessage.EventListener l)
Remove an EventListener.- Parameters:
l
- the listener
-
-