public class NetStreamReceiver extends Thread implements NetStreamDecoder
This class implements a receiver according to specifications the NetStream protocol.
See NetStreamConstants
for a full description of the protocol, the
sender and the receiver.
NetStreamConstants
,
Copyright (c) 2010 University of Luxembourg
NetStreamReceiver.java
Thread.State, Thread.UncaughtExceptionHandler
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
Constructor and Description |
---|
NetStreamReceiver(int port)
New NetStream Receiver, awaiting in its own thread at "localhost" on the
given port, for new graph events.
|
NetStreamReceiver(String hostname,
int port)
New NetStream Receiver, awaiting in its own thread at the given host name
and port, for new graph events.
|
NetStreamReceiver(String hostname,
int port,
boolean debug)
New NetStream Receiver, awaiting in its own thread at the given host name
and port, for new graph events.
|
Modifier and Type | Method and Description |
---|---|
void |
decodeMessage(InputStream in)
Decode one message.
|
ThreadProxyPipe |
getDefaultStream()
Gives the default stream (a ThreadProxyPipe) identified with the name
"default".
|
ThreadProxyPipe |
getStream(String name)
Gives the stream (a ThreadProxyPipe) identified with this name.
|
boolean |
hasActiveConnections()
Ask the receiver about its active connections
|
boolean |
isRunning()
False as soon as the receiver terminates.
|
void |
poll()
Wait until one or several chunks of message are acceptable.
|
void |
quit()
Stop the receiver.
|
void |
register(String name,
ThreadProxyPipe stream)
Register a stream.
|
void |
removeUnpacker() |
void |
run()
Wait for connections, accept them, demultiplexes them and dispatch
messages to registered message boxes.
|
void |
setDebugOn(boolean on)
Enable or disable debugging.
|
void |
setUnpacker(NetStreamUnpacker unpaker)
Sets an optional NetStreamUnpaker whose "unpack" method will be called on
each message.
|
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
public NetStreamReceiver(String hostname, int port) throws IOException, UnknownHostException
hostname
- The host name to listen at messages.port
- The port to listen at messages.IOException
UnknownHostException
public NetStreamReceiver(int port) throws IOException, UnknownHostException
port
- The port to listen at messages.IOException
UnknownHostException
public NetStreamReceiver(String hostname, int port, boolean debug) throws IOException, UnknownHostException
hostname
- The host name to listen at messages.port
- The port to listen at messages.debug
- If true informations are output for each message received.IOException
UnknownHostException
public boolean isRunning()
public void setDebugOn(boolean on)
setDebugOn
in interface NetStreamDecoder
public void quit()
public boolean hasActiveConnections()
public void setUnpacker(NetStreamUnpacker unpaker)
unpaker
- public void removeUnpacker()
public void run()
public void poll()
public ThreadProxyPipe getStream(String name)
NetStreamDecoder
getStream
in interface NetStreamDecoder
name
- Identifier of the stream.public ThreadProxyPipe getDefaultStream()
NetStreamDecoder
getDefaultStream
in interface NetStreamDecoder
public void register(String name, ThreadProxyPipe stream) throws Exception
NetStreamDecoder
register
in interface NetStreamDecoder
name
- Filter only message with this name to the given message box.stream
- The ThreadProxyPipe to push the events to.Exception
- If another Pipe is already registered at the given name.public void decodeMessage(InputStream in) throws IOException
NetStreamDecoder
decodeMessage
in interface NetStreamDecoder
IOException
Copyright © 2015. All rights reserved.