|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface SessionHandler
The SessionHandler represents the incoming view of a BEEP session. It has
several call back methods that correspond to certain events in the lifecycle
of the session. The connectionEstablished(StartSessionRequest)
method
is invoked when the connection to the other peer has been established.
Its purpose is to register zero or more profiles, which will be advertised
in the greeting message. The sessionOpened(Session)
method
is invoked when the greeting from the other peer has been received and the
connectionEstablished method has returned. From that point on until the
session is closed (as indicated by #sessionClosed(Session)
) the
session is in an usable state. When the other peer wants to start a
channel the method #startChannel(Session, StartChannelRequest)
is invoked.
The order of calls to this method is guaranteed to be as follows:
connectionEstablished(StartSessionRequest)
sessionOpened(Session)
#startChannel(Session, StartChannelRequest)
#sessionClosed(Session)
It is possible that instead of the last three methods only the
sessionStartDeclined(int, String)
method is called.
ch.iserver.beepj.Session
Method Summary | |
---|---|
void |
channelStartRequested(StartChannelRequest request)
This method is invoked when the other peer wants to start a new channel. |
void |
connectionEstablished(StartSessionRequest s)
The connectionEstablished method is called by the framework when the connection was established to the other peer. |
void |
sessionClosed()
This method is invoked when the session is closed. |
void |
sessionOpened(Session s)
This method is invoked when the session has been established. |
void |
sessionStartDeclined(int code,
java.lang.String message)
Invoked by the framework if the remote peer declines the session start by sending an error in a negative reply. |
Method Detail |
---|
void connectionEstablished(StartSessionRequest s)
A server typically registers some profiles in this method.
public void connectionEstablished(StartSessionRequest s) { s.registerProfile("http://iana.org/beep/TLS"); }
To send a negative reply, a SessionHandler can cancel the session startup.
public void connectionEstablished(StartSessionRequest s) { s.cancelSession(); }
s
- the session startup objectvoid sessionStartDeclined(int code, java.lang.String message)
code
- the reason codemessage
- the human readable messagevoid sessionOpened(Session s)
s
- the opened Sessionvoid channelStartRequested(StartChannelRequest request)
public void startChannel(StartChannelRequest request) { request.selectProfile(startup.getProfiles()[0]); request.setChannelHandler(new MyChannelHandler()); }Beside accepting the creation of a channel you can also decline it.
public void startChannel(Session s, StartChannelRequest request) { request.cancel(550, "still working"); }Both methods are mutually exclusive. Either you select a profile and a set a channel handler or you cancel the request.
request
- all the information about the request to start a channelvoid sessionClosed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |