public class NodeWatcher extends Object implements de.sciss.app.EventManager.Processor, OSCResponderNode.Action, Constants, Runnable
When a notification message arrives, it is deferred to the
event dispatching thread. Interested objects can register
a listener to receive NodeEvent
s. Right before
the listener's nodeAction
method is called, the
client side Node
status is updated, i.e. the node
linked to or unlinked from neighbouring nodes, the running
playing flags are set etc.
Since these updates occur in the event thread, it is safe to
use the Node
's TreeNode
interface.
Modifier and Type | Field and Description |
---|---|
protected Server |
server |
boolean |
VERBOSE
Set this to
true for debugging
all relevant actions of the watcher, such as starting,
stopping, registering nodes, and updating node status. |
kAddAfter, kAddBefore, kAddReplace, kAddToHead, kAddToTail, kAudioRate, kControlRate, kDemandRate, kDoneFree, kDoneFreeAll, kDoneFreeAllPred, kDoneFreeAllSucc, kDoneFreeGroup, kDoneFreePausePred, kDoneFreePauseSucc, kDoneFreePred, kDoneFreePredGroup, kDoneFreePredGroupDeep, kDoneFreeSucc, kDoneFreeSuccGroup, kDoneFreeSuccGroupDeep, kDoneNothing, kDonePause, kDumpBoth, kDumpHex, kDumpOff, kDumpText, kHeaderAIFF, kHeaderIRCAM, kHeaderNeXT, kHeaderRaw, kHeaderWAVE, kSampleALaw, kSampleDouble, kSampleFloat, kSampleInt16, kSampleInt24, kSampleInt32, kSampleInt8, kSampleMuLaw, kScalarRate
Modifier and Type | Method and Description |
---|---|
void |
addListener(NodeListener l)
Registers a listener to be informed about
node status changes.
|
void |
clear()
Removes all nodes from the list of known nodes.
|
void |
dispose()
Disposes any resources
allocated by this representation.
|
void |
dumpIncomingOSC(int dumpMode)
Changes the way incoming messages are dumped
to the console.
|
List |
getAllNodes()
Queries a list of all registered nodes.
|
boolean |
getFireAllNodes()
Queries the event dispatching mode.
|
boolean |
isWatching()
Queries the watching state
|
static NodeWatcher |
newFrom(Server s)
Returns a
NodeWatcher to
monitor a given server. |
void |
processEvent(de.sciss.app.BasicEvent e)
This is used to dispatch
node events.
|
void |
queryAllNodes(float timeout,
ActionListener doneAction) |
void |
register(Node node)
Adds a node to the list of known nodes.
|
void |
register(Node node,
boolean assumePlaying) |
void |
removeListener(NodeListener l)
Unregisters a listener from being informed about
node status changes.
|
void |
respond(OSCResponderNode r,
de.sciss.net.OSCMessage msg,
long time)
This method is part of the implementation of the
OSCResponderNode.Action interface.
|
void |
run()
Part of internal message queueing.
|
boolean |
setAutoRegister()
Queries whether automatic node registration is enabled.
|
void |
setAutoRegister(boolean onOff)
Decides whether unknown nodes should be automatically
added to the node watcher (usefull for debugging).
|
void |
setFireAllNodes(boolean allNodes)
Decides whether node changes for any node
or only for registered nodes are delivered to
event listeners.
|
void |
start()
Starts the OSC responders that trace incoming
node notification events.
|
void |
stop()
Stops the OSC responders that trace incoming
node notification events.
|
void |
unregister(Node node)
Unregister a node, that is remove it from the list of
known nodes.
|
public boolean VERBOSE
true
for debugging
all relevant actions of the watcher, such as starting,
stopping, registering nodes, and updating node status.protected final Server server
public static NodeWatcher newFrom(Server s) throws IOException
NodeWatcher
to
monitor a given server. Note that the client must
receive notifications, which is true by default when
booting a server. By default, events are only fired
for registered nodes. To change this behaviour, call
setFireAllNodes( true )
s
- the server to which the nodes to be watched belongIOException
Server.notify( boolean )
public void start() throws IOException
IOException
public void stop() throws IOException
IOException
public boolean isWatching()
true
if we are watching for node changes
(i.e. after calling start
), false
otherwise
(i.e. after creating the watcher or after calling stop
).public void register(Node node)
"/n_end"
message arrives. Note that there is a little chance
that "/n_go"
messages are
missed if you register a node after it's new-message
has been sent to the server. A safe way to register
nodes is to call the basic-new-commands and send the
new-message after the registration. for example:
Synth mySynth = Synth.basicNew( "mySynthDef", myServer ); myNodeWatcher.register( mySynth ); myServer.sendMsg( mySynth.newMsg( myTarget, myArgNames, myArgValues ));
node
- the node to registersetFireAllNodes( boolean )
public void register(Node node, boolean assumePlaying)
public void unregister(Node node)
"/n_end"
for that node arrives.node
- the node to unregisterpublic List getAllNodes()
Node
. the list
itself is a copy and maybe modified. It will not be affected by
successive calls to register
or unregister
public void addListener(NodeListener l)
/n_query
message to the server. The fireAllNodes
flag determines whether all status changes are
forwarded to listeners, or only those for previously
registered nodes.l
- listener to be addedsetFireAllNodes( boolean )
public void removeListener(NodeListener l)
l
- listener to be removedpublic void queryAllNodes(float timeout, ActionListener doneAction)
timeout
- maximum time to wait for node info repliesdoneAction
- to be executed when the tree has been queried (can be null
)public void clear()
public void dispose()
public void dumpIncomingOSC(int dumpMode)
dumpMode
- only kDumpNone
and kDumpText
are supported at the moment.Server.dumpOSC( int )
public void setFireAllNodes(boolean allNodes)
allNodes
- true
to deliver events
for all incoming node messages;
false
to deliver events only
if the corresponding node was registeredpublic boolean getFireAllNodes()
setFireAllNodes
for detailssetFireAllNodes( boolean )
public void setAutoRegister(boolean onOff)
onOff
- true
to have nodes automatically created and
registered upon incoming notification events. false
to stop automatic registration.public boolean setAutoRegister()
setAutoRegister( boolean )
public void respond(OSCResponderNode r, de.sciss.net.OSCMessage msg, long time)
respond
in interface OSCResponderNode.Action
public void run()
public void processEvent(de.sciss.app.BasicEvent e)
processEvent
in interface de.sciss.app.EventManager.Processor
Copyright © 2015–2022 SciJava. All rights reserved.