de.avetana.bluetooth.obex
Class SessionNotifierImpl

java.lang.Object
  extended byde.avetana.bluetooth.obex.SessionNotifierImpl
All Implemented Interfaces:
CommandHandler, Connection, SessionNotifier

public class SessionNotifierImpl
extends java.lang.Object
implements SessionNotifier, CommandHandler


Constructor Summary
SessionNotifierImpl(StreamConnectionNotifier locConNot)
           
 
Method Summary
 Connection acceptAndOpen(ServerRequestHandler handler)
          Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client.
 Connection acceptAndOpen(ServerRequestHandler handler, Authenticator auth)
          Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client and the Authenticator to use to respond to authentication challenge and authentication response headers.
 void close()
          First calls streamConClose and then closes the ConnectionNotifier.
 HeaderSet createHeaderSet()
           
 Authenticator getAuthenticator()
           
 StreamConnectionNotifier getConnectionNotifier()
           
 int getMTU()
           
protected  void handleAuthChallenge(HeaderSet request, HeaderSet response)
           
protected  boolean handleAuthResponse(HeaderSet request)
           
 byte[] receiveCommand()
           
 void sendCommand(int commId, byte[] data)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SessionNotifierImpl

public SessionNotifierImpl(StreamConnectionNotifier locConNot)
Method Detail

acceptAndOpen

public Connection acceptAndOpen(ServerRequestHandler handler)
                         throws java.io.IOException
Description copied from interface: SessionNotifier
Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client. No authenticator is associated with this connection, therefore, it is implementation dependent as to how an authentication challenge and authentication response header will be received and processed.

Additional Note for OBEX over Bluetooth

If this method is called on a SessionNotifier object that does not have a ServiceRecord in the SDDB, the ServiceRecord for this object will be added to the SDDB. This method requests the BCC to put the local device in connectable mode so that it will respond to connection attempts by clients.

The following checks are done to verify that the service record provided is valid. If any of these checks fail, then a ServiceRegistrationException is thrown.

This method will not ensure that ServiceRecord associated with this notifier is a completely valid service record. It is the responsibility of the application to ensure that the service record follows all of the applicable syntactic and semantic rules for service record correctness.

Specified by:
acceptAndOpen in interface SessionNotifier
Parameters:
handler - the request handler that will respond to OBEX requests
Returns:
the connection to the client
Throws:
java.io.IOException - if an error occurs in the transport layer

acceptAndOpen

public Connection acceptAndOpen(ServerRequestHandler handler,
                                Authenticator auth)
                         throws java.io.IOException
Description copied from interface: SessionNotifier
Waits for a transport layer connection to be established and specifies the handler to handle the requests from the client and the Authenticator to use to respond to authentication challenge and authentication response headers.

Additional Note for OBEX over Bluetooth

If this method is called on a SessionNotifier object that does not have a ServiceRecord in the SDDB, the ServiceRecord for this object will be added to the SDDB. This method requests the BCC to put the local device in connectable mode so that it will respond to connection attempts by clients.

The following checks are done to verify that the service record provided is valid. If any of these checks fail, then a ServiceRegistrationException is thrown.

This method will not ensure that ServiceRecord associated with this notifier is a completely valid service record. It is the responsibility of the application to ensure that the service record follows all of the applicable syntactic and semantic rules for service record correctness.

Specified by:
acceptAndOpen in interface SessionNotifier
Parameters:
handler - the request handler that will respond to OBEX requests
auth - the Authenticator to use with this connection; if null then no Authenticator will be used
Returns:
the connection to the client
Throws:
java.io.IOException - if an error occurs in the transport layer

getConnectionNotifier

public StreamConnectionNotifier getConnectionNotifier()

createHeaderSet

public HeaderSet createHeaderSet()
Specified by:
createHeaderSet in interface CommandHandler

handleAuthChallenge

protected void handleAuthChallenge(HeaderSet request,
                                   HeaderSet response)
Parameters:
request -
response -

handleAuthResponse

protected boolean handleAuthResponse(HeaderSet request)
Parameters:
request -
Returns:

close

public void close()
First calls streamConClose and then closes the ConnectionNotifier. acceptAndOpen will fail after close has been called.

Specified by:
close in interface Connection

receiveCommand

public byte[] receiveCommand()
                      throws java.io.IOException
Specified by:
receiveCommand in interface CommandHandler
Throws:
java.io.IOException

sendCommand

public void sendCommand(int commId,
                        byte[] data)
                 throws java.io.IOException
Specified by:
sendCommand in interface CommandHandler
Throws:
java.io.IOException

getMTU

public int getMTU()
Specified by:
getMTU in interface CommandHandler

getAuthenticator

public Authenticator getAuthenticator()
Specified by:
getAuthenticator in interface CommandHandler