1 /*
2 * Copyright 2006 Simon Raess
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 package net.sf.beep4j;
17
18
19 /**
20 * Represents the outgoing view of a BEEP channel. It allows to send messages
21 * to the remote peer and to close the channel.
22 *
23 * @author Simon Raess
24 */
25 public interface Channel {
26
27 /**
28 * Gets the URI of the profile that is used by this channel.
29 *
30 * @return the URI of the active profile
31 */
32 String getProfile();
33
34 /**
35 * Gets the session on which this channel runs.
36 *
37 * @return the session
38 */
39 Session getSession();
40
41 /**
42 * Creates a new MessageBuilder object that can be used to create
43 * one Message.
44 *
45 * @return a MessageBuilder implementation
46 */
47 MessageBuilder createMessageBuilder();
48
49 /**
50 * Sends a message on this channel to the remote peer. This
51 * method returns fairly quickly. That is, it does not wait for
52 * the answer to arrive. Instead, the reply is received through
53 * the reply listener.
54 *
55 * @param message the message to be sent
56 * @param listener the listener receiving the reply
57 */
58 void sendMessage(Message message, ReplyHandler listener);
59
60 /**
61 * Closes the channel. The channel is
62 * closed as soon as the conditions specified by section 2.3.1.3 of the
63 * BEEP specification are met. Note that the other peer can decline
64 * the close request. The outcome is communicated throught the
65 * CloseChannelCallback supplied by the client.
66 *
67 * @param callback the callback that gets notified about the outcome of
68 * the close request
69 */
70 void close(CloseChannelCallback callback);
71
72 }