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.javaThread.State, Thread.UncaughtExceptionHandlerMAX_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, yieldpublic NetStreamReceiver(String hostname, int port) throws IOException, UnknownHostException
hostname - The host name to listen at messages.port - The port to listen at messages.IOExceptionUnknownHostExceptionpublic NetStreamReceiver(int port)
throws IOException,
UnknownHostException
port - The port to listen at messages.IOExceptionUnknownHostExceptionpublic 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.IOExceptionUnknownHostExceptionpublic boolean isRunning()
public void setDebugOn(boolean on)
setDebugOn in interface NetStreamDecoderpublic 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)
NetStreamDecodergetStream in interface NetStreamDecodername - Identifier of the stream.public ThreadProxyPipe getDefaultStream()
NetStreamDecodergetDefaultStream in interface NetStreamDecoderpublic void register(String name, ThreadProxyPipe stream) throws Exception
NetStreamDecoderregister in interface NetStreamDecodername - 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
NetStreamDecoderdecodeMessage in interface NetStreamDecoderIOExceptionCopyright © 2015. All rights reserved.