public class RCServer extends cMsgDomainAdapter
| Modifier and Type | Field and Description |
|---|---|
(package private) int |
localUdpPort
UDP port on which to receive messages from the rc client.
|
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgGetHelper> |
sendAndGets
Collection of all of this client's
sendAndGet(cMsgMessage, int)
calls currently in execution. |
(package private) java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgSubscription> |
subscribeAndGets
Collection of all of this client's
subscribeAndGet(String, String, int)
calls currently in execution. |
(package private) java.util.Set<cMsgSubscription> |
subscriptions
Collection of all of this client's message subscriptions which are
cMsgSubscription objects. |
connected, debug, description, domain, host, name, receiving, shutdownHandler, UDL, UDLremainder| Constructor and Description |
|---|
RCServer()
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
This method results in this object
becoming functionally useless.
|
void |
connect()
Method to connect to the rc client from this server.
|
void |
disconnect()
Method to close the connection to the rc client.
|
java.lang.String |
getString()
Returns a string back to the top level API user indicating the host
and port of the client that this server is communicating with.
|
void |
send(cMsgMessage message)
Method to send a message/command to the rc client.
|
cMsgMessage |
sendAndGet(cMsgMessage message,
int timeout)
The message is sent as it would be in the
send(org.jlab.coda.cMsg.cMsgMessage) method except that the
senderToken and creator are set. |
void |
setUDL(java.lang.String UDL)
Set the UDL of the client which may be a semicolon separated
list of (sub)UDLs in this domain.
|
cMsgSubscriptionHandle |
subscribe(java.lang.String subject,
java.lang.String type,
cMsgCallbackInterface cb,
java.lang.Object userObj)
This is a method to subscribe to receive messages of a subject and type from the rc client.
|
cMsgMessage |
subscribeAndGet(java.lang.String subject,
java.lang.String type,
int timeout)
This method is like a one-time subscribe.
|
int |
syncSend(cMsgMessage message,
int timeout)
Method to send a "ping" command to the rc client.
|
void |
unsubscribe(cMsgSubscriptionHandle obj)
Method to unsubscribe a previous subscription.
|
flush, getCurrentUDL, getDebug, getDescription, getDomain, getHost, getInfo, getName, getServerHost, getServerPort, getShutdownHandler, getUDL, getUDLRemainder, isConnected, isReceiving, monitor, setDebug, setDescription, setName, setShutdownHandler, setUDLRemainder, shutdownClients, shutdownServers, start, stopint localUdpPort
java.util.Set<cMsgSubscription> subscriptions
cMsgSubscription objects. This set is synchronized.java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgSubscription> subscribeAndGets
subscribeAndGet(String, String, int)
calls currently in execution.
SubscribeAndGets are very similar to subscriptions and can be thought of as
one-shot subscriptions.
Key is receiverSubscribeId object, value is cMsgSubscription
object.java.util.concurrent.ConcurrentHashMap<java.lang.Integer,cMsgGetHelper> sendAndGets
sendAndGet(cMsgMessage, int)
calls currently in execution.
Key is senderToken object, value is cMsgGetHelper object.public RCServer()
throws cMsgException
cMsgException - if cannot find host name.public java.lang.String getString()
public void setUDL(java.lang.String UDL)
throws cMsgException
setUDL in interface cMsgDomainInterfacesetUDL in class cMsgDomainAdapterUDL - UDL of clientcMsgException - if UDL is null or no valid UDL existspublic void connect()
throws cMsgException
connect in interface cMsgDomainInterfaceconnect in class cMsgDomainAdaptercMsgException - if there are problems parsing the UDL,
communication problems with the client,
or cannot start up a TCP listening threadpublic void close()
public void disconnect()
disconnect in interface cMsgDomainInterfacedisconnect in class cMsgDomainAdapterpublic void send(cMsgMessage message) throws cMsgException
send in interface cMsgDomainInterfacesend in class cMsgDomainAdaptermessage - message to sendcMsgException - if there are communication problems with the server;
text is null or blankpublic int syncSend(cMsgMessage message, int timeout) throws cMsgException
syncSend in interface cMsgDomainInterfacesyncSend in class cMsgDomainAdaptermessage - message to sendtimeout - ignoredcMsgException - if there is a timeoutpublic cMsgSubscriptionHandle subscribe(java.lang.String subject, java.lang.String type, cMsgCallbackInterface cb, java.lang.Object userObj) throws cMsgException
subscribe in interface cMsgDomainInterfacesubscribe in class cMsgDomainAdaptersubject - message subjecttype - message typecb - callback object whose single method is called upon receiving a message
of subject and typeuserObj - any user-supplied object to be given to the callback method as an argumentcMsgException - if the subject, type, or callback is null;
an identical subscription already exists;
if not connected to an rc clientpublic void unsubscribe(cMsgSubscriptionHandle obj) throws cMsgException
unsubscribe in interface cMsgDomainInterfaceunsubscribe in class cMsgDomainAdapterobj - the object returned from a subscribe callcMsgException - if there is no connection with the rc client; obj is nullpublic cMsgMessage subscribeAndGet(java.lang.String subject, java.lang.String type, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
subscribeAndGet in interface cMsgDomainInterfacesubscribeAndGet in class cMsgDomainAdaptersubject - subject of message desired from servertype - type of message desired from servertimeout - time in milliseconds to wait for a messagecMsgException - if there are communication problems with rc client;
subject and/or type is null or blankjava.util.concurrent.TimeoutException - if timeout occurspublic cMsgMessage sendAndGet(cMsgMessage message, int timeout) throws cMsgException, java.util.concurrent.TimeoutException
send(org.jlab.coda.cMsg.cMsgMessage) method except that the
senderToken and creator are set. A marked response can be received from a client
regardless of its subject or type.
NOTE: Disconnecting when one thread is in the waiting part of a sendAndGet may cause that
thread to block forever. It is best to always use a timeout with sendAndGet so the thread
is assured of eventually resuming execution.sendAndGet in interface cMsgDomainInterfacesendAndGet in class cMsgDomainAdaptermessage - message sent to clienttimeout - time in milliseconds to wait for a response message, zero means wait forever.cMsgException - if there are communication problems with the client;
subject and/or type is null or blankjava.util.concurrent.TimeoutException - if timeout occurs