blob: 5fa1c8c7bf30fd760a70a052454ed8f1d4fb6eb3 [file] [log] [blame]
Jerome Poichet7c997852014-05-20 10:50:05 -07001/*
2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.google.polo.wire;
18
19import java.io.IOException;
20
21import com.google.polo.exception.PoloException;
22import com.google.polo.pairing.message.PoloMessage;
23
24/**
25 * Public interface for transport-layer implementations of the pairing
26 * protocol.
27 */
28public interface PoloWireInterface {
29
30 /**
31 * Returns the next message from the wire.
32 *
33 * @return a new PoloMessage instance
34 * @throws IOException if an error occurred while reading
35 * @throws PoloException if a protocol fault occurred
36 */
37 public PoloMessage getNextMessage() throws IOException, PoloException;
38
39 /**
40 * Returns the next message from the wire.
41 *
42 * @param type the required message type to be read
43 * @return a new PoloMessage instance
44 * @throws IOException if an error occurred while reading
45 * @throws PoloException if the next message did not match the requested
46 * type.
47 */
48 public PoloMessage getNextMessage(PoloMessage.PoloMessageType type)
49 throws IOException, PoloException;
50
51 /**
52 * Send a normal message out on the wire.
53 *
54 * @param message the message to send
55 * @throws IOException if an error occurred while sending
56 * @throws PoloException if the message was not well formed
57 */
58 public void sendMessage(PoloMessage message)
59 throws IOException, PoloException;
60
61 /**
62 * Send an error message out on the wire, based on an exception.
63 *
64 * @param e the exception causing the error
65 * @throws IOException if an error occurred while sending
66 */
67 public void sendErrorMessage(Exception e) throws IOException;
68
69}