blob: ebad44265b42da7b82146b1b0eee1274f389106f [file] [log] [blame]
Madan Jampaniab6d3112014-10-02 16:30:14 -07001package org.onlab.netty;
2
3import java.io.IOException;
4
5/**
6 * Interface for low level messaging primitives.
7 */
8public 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}