Package org.astrogrid.samp.test
Class MessageSender
- java.lang.Object
-
- org.astrogrid.samp.test.MessageSender
-
- Direct Known Subclasses:
MessageSender.AsynchSender,MessageSender.NotifySender,MessageSender.SynchSender
public abstract class MessageSender extends java.lang.ObjectSends a message to one or more other SAMP clients. Intended for use from the command line.- Since:
- 23 Jul 2008
- Author:
- Mark Taylor
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static classMessageSender.AsynchSenderMessageSender implementation which uses the Asynchronous Call/Response pattern.private static classMessageSender.BlockingMapMap implementation which dispenses its contents via an iterator which will block until all the results are in.private static classMessageSender.BlockingSetSet implementation which dispenses its contents via an iterator which will block until all results are in.private static classMessageSender.MetaClientClient implementation which may know about metadata.private static classMessageSender.NotifySenderMessageSender implementation which uses the Notify pattern.private static classMessageSender.SynchSenderMessageSender implementation which uses the Synchronous Call/Response pattern.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Loggerlogger_
-
Constructor Summary
Constructors Constructor Description MessageSender()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) abstract java.util.MapgetResponses(HubConnection connection, Message msg, java.lang.String[] recipientIds)Sends a message to a given list of recipients.static voidmain(java.lang.String[] args)Main method.private static java.lang.String[]namesToIds(HubConnection conn, java.lang.String[] names)Translates an array of client names to client IDs.static intrunMain(java.lang.String[] args)Does the work for the main method.(package private) voidshowResults(HubConnection connection, Message msg, java.lang.String[] recipientIds, java.io.PrintStream out)Sends a message to a list of recipients and displays the results on an output stream.
-
-
-
Method Detail
-
getResponses
abstract java.util.Map getResponses(HubConnection connection, Message msg, java.lang.String[] recipientIds) throws java.io.IOException
Sends a message to a given list of recipients. IfrecipientIdsis null, then will be sent to all subscribed clients.- Parameters:
connection- hub connectionmsg- message to sendrecipientIds- array of recipients to target, or null- Returns:
- responder Client -> Response map
- Throws:
java.io.IOException
-
showResults
void showResults(HubConnection connection, Message msg, java.lang.String[] recipientIds, java.io.PrintStream out) throws java.io.IOException
Sends a message to a list of recipients and displays the results on an output stream.- Parameters:
connection- hub connectionmsg- message to sendrecipientIds- array of recipients to target, or nulldestination- print stream- Throws:
java.io.IOException
-
namesToIds
private static java.lang.String[] namesToIds(HubConnection conn, java.lang.String[] names) throws SampException
Translates an array of client names to client IDs. If some or all cannot be identified, an exception is thrown.- Parameters:
conn- hub connectionnames- array of client names, interpreted case-insensitively- Returns:
- array of client ids corresponding to
names - Throws:
SampException
-
main
public static void main(java.lang.String[] args) throws java.io.IOExceptionMain method. Use -help flag for documentation.- Throws:
java.io.IOException
-
runMain
public static int runMain(java.lang.String[] args) throws java.io.IOExceptionDoes the work for the main method.- Throws:
java.io.IOException
-
-