| 1 |
package org.astrogrid.samp.client; |
| 2 |
|
| 3 |
import java.util.Map; |
| 4 |
import org.astrogrid.samp.Message; |
| 5 |
|
| 6 |
/** |
| 7 |
* Interface for a client which wishes to receive messages. |
| 8 |
* In most cases it is more convenient to subclass the abstract class |
| 9 |
* {@link AbstractMessageHandler} than to implement this interface directly. |
| 10 |
* |
| 11 |
* @author Mark Taylor |
| 12 |
* @since 16 Jul 2008 |
| 13 |
*/ |
| 14 |
public interface MessageHandler { |
| 15 |
|
| 16 |
/** |
| 17 |
* Returns a Subscriptions map corresponding to the messages |
| 18 |
* handled by this object. |
| 19 |
* Only messages with MTypes which match the keys of this map will |
| 20 |
* be passed to this object. |
| 21 |
* |
| 22 |
* @return {@link org.astrogrid.samp.Subscriptions}-like map |
| 23 |
*/ |
| 24 |
Map getSubscriptions(); |
| 25 |
|
| 26 |
/** |
| 27 |
* Processes a message which does not require a response. |
| 28 |
* |
| 29 |
* @param connection hub connection |
| 30 |
* @param senderId public ID of client which sent the message |
| 31 |
* @param message message |
| 32 |
*/ |
| 33 |
void receiveNotification( HubConnection connection, |
| 34 |
String senderId, Message message ) |
| 35 |
throws Exception; |
| 36 |
|
| 37 |
/** |
| 38 |
* Processes a message which does require a response. |
| 39 |
* Implementations should make sure that a subsequent call to |
| 40 |
* <code>connection.reply()</code> is made using the |
| 41 |
* supplied <code>msgId</code>. |
| 42 |
* |
| 43 |
* @param connection hub connection |
| 44 |
* @param senderId public ID of client which sent the message |
| 45 |
* @param msgId message ID |
| 46 |
* @param message message |
| 47 |
*/ |
| 48 |
void receiveCall( HubConnection connection, |
| 49 |
String senderId, String msgId, Message message ) |
| 50 |
throws Exception; |
| 51 |
} |