blob: bf9333168e018ed1df514d7adacc43d909325cf4 [file] [log] [blame]
Madan Jampaniab6d3112014-10-02 16:30:14 -07001package org.onlab.netty;
2
3import java.io.IOException;
4
Madan Jampani24f9efb2014-10-24 18:56:23 -07005import com.google.common.util.concurrent.ListenableFuture;
6
Madan Jampaniab6d3112014-10-02 16:30:14 -07007/**
8 * Interface for low level messaging primitives.
9 */
10public interface MessagingService {
11 /**
12 * Sends a message asynchronously to the specified communication end point.
13 * The message is specified using the type and payload.
14 * @param ep end point to send the message to.
15 * @param type type of message.
Madan Jampani53e44e62014-10-07 12:39:51 -070016 * @param payload message payload bytes.
Madan Jampaniab6d3112014-10-02 16:30:14 -070017 * @throws IOException
18 */
Madan Jampani53e44e62014-10-07 12:39:51 -070019 public void sendAsync(Endpoint ep, String type, byte[] payload) throws IOException;
Madan Jampaniab6d3112014-10-02 16:30:14 -070020
21 /**
22 * Sends a message synchronously and waits for a response.
23 * @param ep end point to send the message to.
24 * @param type type of message.
25 * @param payload message payload.
26 * @return a response future
27 * @throws IOException
28 */
Madan Jampani24f9efb2014-10-24 18:56:23 -070029 public ListenableFuture<byte[]> sendAndReceive(Endpoint ep, String type, byte[] payload) throws IOException;
Madan Jampaniab6d3112014-10-02 16:30:14 -070030
31 /**
32 * Registers a new message handler for message type.
33 * @param type message type.
34 * @param handler message handler
35 */
36 public void registerHandler(String type, MessageHandler handler);
37
38 /**
39 * Unregister current handler, if one exists for message type.
40 * @param type message type
41 */
42 public void unregisterHandler(String type);
Madan Jampani53e44e62014-10-07 12:39:51 -070043}