org.jlab.coda.cMsg.RCBroadcastDomain
Class RCBroadcast

java.lang.Object
  extended by org.jlab.coda.cMsg.cMsgDomainAdapter
      extended by org.jlab.coda.cMsg.RCBroadcastDomain.RCBroadcast
All Implemented Interfaces:
cMsgDomainInterface

public class RCBroadcast
extends cMsgDomainAdapter

This class implements the runcontrol broadcast (rdb) domain.

Version:
1.0
Author:
Carl Timmer

Field Summary
 
Fields inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter
connected, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder
 
Constructor Summary
RCBroadcast()
           
 
Method Summary
 void connect()
          Method to connect to rc clients from this server.
 void disconnect()
          Method to stop listening for packets from rc clients.
 void send(cMsgMessage message)
          Method to send an abort command to the rc client.
 java.lang.Object subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj)
          Method to subscribe to receive messages from rc clients.
 cMsgMessage subscribeAndGet(java.lang.String subject, java.lang.String type, int timeout)
          This method is like a one-time subscribe.
 void unsubscribe(java.lang.Object obj)
          Method to unsubscribe a previous subscription.
 
Methods inherited from class org.jlab.coda.cMsg.cMsgDomainAdapter
flush, getDescription, getDomain, getHost, getName, getShutdownHandler, getString, getUDL, getUDLRemainder, isConnected, isReceiving, monitor, sendAndGet, setDescription, setName, setShutdownHandler, setUDL, setUDLRemainder, shutdownClients, shutdownServers, start, stop, syncSend
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RCBroadcast

public RCBroadcast()
            throws cMsgException
Throws:
cMsgException
Method Detail

connect

public void connect()
             throws cMsgException
Method to connect to rc clients from this server.

Specified by:
connect in interface cMsgDomainInterface
Overrides:
connect in class cMsgDomainAdapter
Throws:
cMsgException - if there are problems parsing the UDL or creating the UDP socket

disconnect

public void disconnect()
Method to stop listening for packets from rc clients.

Specified by:
disconnect in interface cMsgDomainInterface
Overrides:
disconnect in class cMsgDomainAdapter

send

public void send(cMsgMessage message)
          throws cMsgException
Method to send an abort command to the rc client. Fill in the senderHost with the host and the userInt with the port of the rc client to abort.

Specified by:
send in interface cMsgDomainInterface
Overrides:
send in class cMsgDomainAdapter
Parameters:
message - message to send
Throws:
cMsgException - if there are communication problems with the rc client

subscribe

public java.lang.Object subscribe(java.lang.String subject,
                                  java.lang.String type,
                                  cMsgCallbackInterface cb,
                                  java.lang.Object userObj)
                           throws cMsgException
Method to subscribe to receive messages from rc clients. In this domain, subject and type are ignored and set to the preset values of "s" and "t". The combination of arguments must be unique. In other words, only 1 subscription is allowed for a given set of callback and userObj.

Specified by:
subscribe in interface cMsgDomainInterface
Overrides:
subscribe in class cMsgDomainAdapter
Parameters:
subject - ignored and set to "s"
type - ignored and set to "t"
cb - callback object whose single method is called upon receiving a message of subject and type
userObj - any user-supplied object to be given to the callback method as an argument
Returns:
handle object to be used for unsubscribing
Throws:
cMsgException - if the callback, subject and/or type is null or blank; an identical subscription already exists; if not connected to an rc client

unsubscribe

public void unsubscribe(java.lang.Object obj)
                 throws cMsgException
Method to unsubscribe a previous subscription.

Specified by:
unsubscribe in interface cMsgDomainInterface
Overrides:
unsubscribe in class cMsgDomainAdapter
Parameters:
obj - the object "handle" returned from a subscribe call
Throws:
cMsgException - if there is no connection with rc clients; object is null

subscribeAndGet

public cMsgMessage subscribeAndGet(java.lang.String subject,
                                   java.lang.String type,
                                   int timeout)
                            throws cMsgException,
                                   java.util.concurrent.TimeoutException
This method is like a one-time subscribe. The rc server grabs an incoming message and sends that to the caller. In this domain, subject and type are ignored and set to the preset values of "s" and "t".

Specified by:
subscribeAndGet in interface cMsgDomainInterface
Overrides:
subscribeAndGet in class cMsgDomainAdapter
Parameters:
subject - ignored and set to "s"
type - ignored and set to "t"
timeout - time in milliseconds to wait for a message
Returns:
response message
Throws:
cMsgException - if there are communication problems with rc client; subject and/or type is null or blank
java.util.concurrent.TimeoutException - if timeout occurs