net.sf.beep4j
Interface SessionHandler

All Known Implementing Classes:
SessionHandlerAdapter

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:

It is possible that instead of the last three methods only the sessionStartDeclined(int, String) method is called.

Author:
Simon Raess
See Also:
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

connectionEstablished

void connectionEstablished(StartSessionRequest s)
The connectionEstablished method is called by the framework when the connection was established to the other peer. The purpose of this method is to send the BEEP greeting message (see 2.3.1.1 of RFC 3080).

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();
   }
 

Parameters:
s - the session startup object

sessionStartDeclined

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.

Parameters:
code - the reason code
message - the human readable message

sessionOpened

void sessionOpened(Session s)
This method is invoked when the session has been established.

Parameters:
s - the opened Session

channelStartRequested

void channelStartRequested(StartChannelRequest request)
This method is invoked when the other peer wants to start a new channel. The passed in ChannelStartup method should be used to select a suitable channel and to install a ChannelHandler.
   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.

Parameters:
request - all the information about the request to start a channel

sessionClosed

void sessionClosed()
This method is invoked when the session is closed.



Copyright © 2007 null. All Rights Reserved.