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.Object
Sends 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 class
MessageSender.AsynchSender
MessageSender implementation which uses the Asynchronous Call/Response pattern.private static class
MessageSender.BlockingMap
Map implementation which dispenses its contents via an iterator which will block until all the results are in.private static class
MessageSender.BlockingSet
Set implementation which dispenses its contents via an iterator which will block until all results are in.private static class
MessageSender.MetaClient
Client implementation which may know about metadata.private static class
MessageSender.NotifySender
MessageSender implementation which uses the Notify pattern.private static class
MessageSender.SynchSender
MessageSender implementation which uses the Synchronous Call/Response pattern.
-
Field Summary
Fields Modifier and Type Field Description private static java.util.logging.Logger
logger_
-
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.Map
getResponses(HubConnection connection, Message msg, java.lang.String[] recipientIds)
Sends a message to a given list of recipients.static void
main(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 int
runMain(java.lang.String[] args)
Does the work for the main method.(package private) void
showResults(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. IfrecipientIds
is 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.IOException
Main method. Use -help flag for documentation.- Throws:
java.io.IOException
-
runMain
public static int runMain(java.lang.String[] args) throws java.io.IOException
Does the work for the main method.- Throws:
java.io.IOException
-
-