/**
   * Creates new ServerSession.
   *
   * @param trans the connection to the client
   * @param handler the event listener that will process requests
   * @param auth the authenticator to use with this connection
   * @throws IOException if an error occurred while opening the input and output streams
   */
  public ServerSession(ObexTransport trans, ServerRequestHandler handler, Authenticator auth)
      throws IOException {
    mAuthenticator = auth;
    mTransport = trans;
    mInput = mTransport.openInputStream();
    mOutput = mTransport.openOutputStream();
    mListener = handler;
    mMaxPacketLength = 256;

    mClosed = false;
    mProcessThread = new Thread(this);
    mProcessThread.start();

    mData = new ObexByteBuffer(32);
    mHeaderBuffer = new ObexByteBuffer(32);
  }
 /**
  * Closes the server session - in detail close I/O streams and the underlying transport layer.
  * Internal flag is also set so that later attempt to read/write will throw an exception.
  */
 public synchronized void close() {
   if (mListener != null) {
     mListener.onClose();
   }
   try {
     mInput.close();
     mOutput.close();
     mTransport.close();
     mClosed = true;
   } catch (Exception e) {
   }
   mTransport = null;
   mInput = null;
   mOutput = null;
   mListener = null;
 }