Madan Jampani | c9ed9be | 2014-10-02 16:13:11 -0700 | [diff] [blame^] | 1 | package org.onlab.netty; |
Madan Jampani | 890bc35 | 2014-10-01 22:35:29 -0700 | [diff] [blame] | 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | /** |
| 6 | * Interface for low level messaging primitives. |
| 7 | */ |
| 8 | public interface MessagingService { |
| 9 | /** |
| 10 | * Sends a message asynchronously to the specified communication end point. |
| 11 | * The message is specified using the type and payload. |
| 12 | * @param ep end point to send the message to. |
| 13 | * @param type type of message. |
| 14 | * @param payload message payload. |
| 15 | * @throws IOException |
| 16 | */ |
| 17 | public void sendAsync(Endpoint ep, String type, Object payload) throws IOException; |
| 18 | |
| 19 | /** |
| 20 | * Sends a message synchronously and waits for a response. |
| 21 | * @param ep end point to send the message to. |
| 22 | * @param type type of message. |
| 23 | * @param payload message payload. |
| 24 | * @return a response future |
| 25 | * @throws IOException |
| 26 | */ |
| 27 | public <T> Response<T> sendAndReceive(Endpoint ep, String type, Object payload) throws IOException; |
| 28 | |
| 29 | /** |
| 30 | * Registers a new message handler for message type. |
| 31 | * @param type message type. |
| 32 | * @param handler message handler |
| 33 | */ |
| 34 | public void registerHandler(String type, MessageHandler handler); |
| 35 | |
| 36 | /** |
| 37 | * Unregister current handler, if one exists for message type. |
| 38 | * @param type message type |
| 39 | */ |
| 40 | public void unregisterHandler(String type); |
| 41 | } |