public class DmhClient extends Object implements DmhClientItf, Runnable
Use the class only for a constructor call. Use the interface classname in your application. For example:
DmhClientItf dmh = new DmhClient();
STATE_CLOSING, STATE_COMM_ERROR, STATE_CONNECTED, STATE_DISCONNECTED, STATE_NAME_RESOLUTION, STATE_SETUP_IN_PROGRESS| Constructor and Description |
|---|
DmhClient()
An implementation of interface DmhClientItf.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close(String boxname)
Stop using a mailbox - disarm receiving if listening, discard any pending messages,
and remove from existence if it exists.
|
int[] |
count(String boxname)
Obtain mailbox message counts.
|
void |
disarm()
Cancel all mailbox receiving for the connection.
|
void |
disarm(String boxname)
Un-register the listener from a mailbox.
|
void |
disconnect()
Clean-up resources such as network connections that are being
used by this interface.
|
String |
doXact(String destbox,
String msg)
Send a message and wait for a reply.
|
String |
doXact(String destbox,
String msg,
int secs_timeout)
Send a message and wait for a reply.
|
String |
doXact(String destbox,
String msg,
String replybox)
Send a message and wait for a reply.
|
String |
doXact(String destbox,
String msg,
String replybox,
int secs_timeout)
Send a message and wait for a reply.
|
void |
flush(String boxname)
Empty a mailbox of any pending messages.
|
String |
getClientID()
Get the server's unique ID string for the client connection.
|
int |
getDefaultTimeout()
Get the current default timeout that is used on DoXact calls.
|
String |
getDescription()
returns the client description
|
String |
getGroupname()
return the DMH Groupname as provided to the init() method.
|
String |
getHostname()
Return the TCP/IP hostname of the local computer
|
String |
getMhGroup()
If you have a connection, getMhgroup() returns hostname:port
of the DMH server else an empty string
|
String |
getProduct()
Obtain the vendor product id.
|
int |
getState()
Obtain an integer code representing communication status.
|
int |
getTraceBits()
get the trace bitfield settings
|
String |
getVersion()
Obtain the DMH compatibility version.
|
int |
groupnamePort(String Groupname)
Return the socket port that a DMH groupname is mapped to.
|
String |
init(String hostname,
int port)
Initialize and connect to a DMH server.
|
String |
init(String hostname,
String groupname)
Initialize and connect to a DMH server.
|
void |
put(String mailbox,
String message)
Send a message to a named mailbox.
|
void |
putr(String destbox,
String replybox,
String message)
Send a message to a mailbox with a reply mailbox indicated.
|
void |
run()
Run is public for Thread start to call, not for applications to call.
|
String |
serverStatus()
Obtain the current message system status as a text list.
|
int |
setDefaultTimeout(int secs_timeout)
Set the default timeout that is used on DoXact calls.
|
void |
setDescription(String description)
Set the description for the client that is shown by the
"Identify" button from the DMH Status window.
|
DmhLostServerItf |
setLostServer(DmhLostServerItf handler)
Register a handler that gets called if the connection to the
DMH server is lost.
|
DmhTraceItf |
setTrace(DmhTraceItf handler)
set the Trace output handler, return the previous value
|
int |
setTraceBits(int tracebits)
Control the output of trace information.
|
String |
timedReceive(String boxname,
int secs_timeout)
Wait for a message to be received.
|
String |
toString() |
void |
whenMsg(String boxname,
DmhReceiveItf handler)
Register a callback object to receive the next
message available in mailbox boxname.
|
void |
whenMsgAgain()
This method is called by the logic of your dmhReceive() method
to specify that the current
handler object should be used to process the next message
received in the same destination mailbox.
|
String[][] |
whenMsgDump()
Dump the list of active mailbox listeners.
|
public DmhClient()
Use the class only for a constructor call. Use the interface classname in your application. For example:
DmhClientItf dmh = new DmhClient();
public void close(String boxname)
throws Exception
DmhClientItfclose in interface DmhClientItfboxname - The name of the mailbox that is to be closed.Exception - if there is no connectionpublic int[] count(String boxname)
throws Exception
DmhClientItfcount in interface DmhClientItfboxname - The mailbox name.
Exception - if there is no connectionpublic void disarm()
throws Exception
DmhClientItfdisarm in interface DmhClientItfExceptionpublic void disarm(String boxname)
throws Exception
DmhClientItfdisarm in interface DmhClientItfboxname - The name of the mailbox that is serving as the destination for the sender(s) of the message(s).Exception - if there is no connectionpublic void disconnect()
DmhClientItfdisconnect in interface DmhClientItfpublic String doXact(String destbox,
String msg)
throws Exception
DmhClientItfdoXact in interface DmhClientItfdestbox - The mailbox name of the server to which the message is sent.msg - The message string.Exception - for improper arguments or a broken connectionpublic String doXact(String destbox,
String msg,
int secs_timeout)
throws Exception
DmhClientItfdoXact in interface DmhClientItfdestbox - The mailbox name of the server to which the message is sent.msg - The message string.secs_timeout - The maximum time to wait for the reply in seconds.Exception - for improper arguments or a broken connectionpublic String doXact(String destbox,
String msg,
String replybox)
throws Exception
DmhClientItfdoXact in interface DmhClientItfdestbox - The mailbox name of the server to which the message is sent.msg - The message string.replybox - A mailbox name specified for receiving the reply message.Exception - for improper arguments or a broken connectionpublic String doXact(String destbox,
String msg,
String replybox,
int secs_timeout)
throws Exception
DmhClientItfdoXact in interface DmhClientItfdestbox - The mailbox name of the server to which the message is sent.msg - The message string.replybox - A mailbox name specified for receiving the reply message.secs_timeout - The maximum time to wait for the reply in seconds.Exception - for improper arguments or a broken connectionpublic void flush(String boxname)
throws Exception
DmhClientItfflush in interface DmhClientItfboxname - The name of the mailbox that is to be emptied.Exception - if no connection.public String getClientID()
DmhClientItfgetClientID in interface DmhClientItfpublic int getDefaultTimeout()
DmhClientItfgetDefaultTimeout in interface DmhClientItfpublic String getDescription()
DmhClientItfgetDescription in interface DmhClientItfpublic String getGroupname()
DmhClientItfgetGroupname in interface DmhClientItfpublic String getHostname()
DmhClientItfgetHostname in interface DmhClientItfpublic String getMhGroup()
DmhClientItfgetMhGroup in interface DmhClientItfpublic String getProduct()
DmhClientItfA proprietary or competitive version of this interface should return a different value.
getProduct in interface DmhClientItfpublic int getState()
DmhClientItfgetState in interface DmhClientItfpublic int getTraceBits()
DmhClientItfgetTraceBits in interface DmhClientItfpublic String getVersion()
DmhClientItfgetVersion in interface DmhClientItfpublic int groupnamePort(String Groupname)
DmhClientItfgroupnamePort in interface DmhClientItfpublic String init(String hostname,
int port)
throws Exception
DmhClientItfinit in interface DmhClientItfhostname - the TCP/IP hostname of the DMH server,
may also be the IP number as a string.
May be null to represent your own system.port - the socket port number for the serverException - if the connection attempt failspublic String init(String hostname,
String groupname)
throws Exception
DmhClientItfinit in interface DmhClientItfhostname - the TCP/IP hostname of the DMH server,
may also be the IP number as a string.
May be null to represent your own system.groupname - the name of the DMH message group.
Group names are hashed to an integer
port number. The init() method can also be
called directly with an integer port number.Exception - if the connection attempt failspublic void put(String mailbox,
String message)
throws Exception
DmhClientItfput in interface DmhClientItfmailbox - The destination mailbox name.message - The message string. String characters are converted to
UTF-8 encoding, so that you can safely send
International characters.Exceptionpublic void putr(String destbox,
String replybox,
String message)
throws Exception
DmhClientItfputr in interface DmhClientItfdestbox - The destination mailbox name.replybox - The reply mailbox.message - The message string. String characters are converted to
UTF-8 encoding, so that you can safely send
International characters.Exceptionpublic void run()
run in interface Runnablepublic String serverStatus()
throws Exception
DmhClientItfserverStatus in interface DmhClientItfExceptionpublic int setDefaultTimeout(int secs_timeout)
throws Exception
DmhClientItfsetDefaultTimeout in interface DmhClientItfsecs_timeout - The default maximum time to wait for reply messages.
The value must be >= 1 and < 86400Exceptionpublic void setDescription(String description)
DmhClientItfsetDescription in interface DmhClientItfdescription - A user supplied description of the application
process.public DmhLostServerItf setLostServer(DmhLostServerItf handler)
DmhClientItfsetLostServer in interface DmhClientItfhandler - An object that implements the DmhLostServerItf interfacepublic DmhTraceItf setTrace(DmhTraceItf handler)
DmhClientItfsetTrace in interface DmhClientItfpublic int setTraceBits(int tracebits)
DmhClientItfsetTraceBits in interface DmhClientItftracebits - Treated as a bitfieldpublic String timedReceive(String boxname,
int secs_timeout)
throws Exception
DmhClientItftimedReceive in interface DmhClientItfboxname - The mailbox name.secs_timeout - The maximum time to wait in seconds.Exceptionpublic String toString()
toString in class Objectpublic void whenMsg(String boxname,
DmhReceiveItf handler)
throws Exception
DmhClientItfAn application should insure that the dmhReceive() call completes execution in due course - the application should not try to "live" in a dmhReceive() call.
The message is removed (consumed) from the mailbox by the action of receiving it. There should not be more than one receiver per mailbox.
whenMsg in interface DmhClientItfboxname - The name of the mailbox that is serving as the destination for sent messages.handler - An object that implements the DmhReceiveItf interface.Exception - if no connectionpublic void whenMsgAgain()
throws Exception
DmhClientItfwhenMsgAgain in interface DmhClientItfExceptionpublic String[][] whenMsgDump()
DmhClientItfwhenMsgDump in interface DmhClientItf