Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 1 | package org.onlab.netty; |
| 2 | |
| 3 | import java.io.IOException; |
| 4 | |
| 5 | /** |
| 6 | * A unit of communication. |
| 7 | * Has a payload. Also supports a feature to respond back to the sender. |
| 8 | */ |
| 9 | public interface Message { |
| 10 | |
| 11 | /** |
| 12 | * Returns the payload of this message. |
| 13 | * @return message payload. |
| 14 | */ |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 15 | public byte[] payload(); |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 16 | |
| 17 | /** |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 18 | * Sends a reply back to the sender of this message. |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 19 | * @param data payload of the response. |
| 20 | * @throws IOException if there is a communication error. |
| 21 | */ |
Madan Jampani | 53e44e6 | 2014-10-07 12:39:51 -0700 | [diff] [blame] | 22 | public void respond(byte[] data) throws IOException; |
Madan Jampani | ab6d311 | 2014-10-02 16:30:14 -0700 | [diff] [blame] | 23 | } |