Class BluetoothServer

  extended by java.lang.Thread
      extended by ch.aplu.bluetooth.BluetoothServer
All Implemented Interfaces:

public class BluetoothServer
extends java.lang.Thread

Class that creates a Bluetooth server thread. Keep in mind that the server must be started before any client tries to connect.

Nested Class Summary
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
Field Summary
Fields inherited from class java.lang.Thread
Constructor Summary
BluetoothServer(BtListener listener)
BluetoothServer(BtListener listener, boolean isNxtClient)
          Creates a server instance.
Method Summary
 void cancel()
          Cancels the blocking waitForConnection() or closes an opened connection.
 void close()
          Closes the opened connection.
 boolean isCanceled()
          Returns true, if cancel was previously called.
 void run()
          For internal use only.
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail


public BluetoothServer(BtListener listener,
                       boolean isNxtClient)
Creates a server instance. The given listener gets callback information when a client connects.

listener - the BtListener to get connnect information


public BluetoothServer(BtListener listener)
Method Detail


public void run()
For internal use only.

Specified by:
run in interface java.lang.Runnable
run in class java.lang.Thread


public void cancel()
Cancels the blocking waitForConnection() or closes an opened connection. If the server is actually connected to a client, cancel() will also inform the connected client staying in a blocking read method with an end-of-stream value.


public void close()
Closes the opened connection. Any blocking read method will throw an IOException. A connected client waiting in a blocking read method will get an end-of-stream value. If no transfer is underway, returns immediately.


public boolean isCanceled()
Returns true, if cancel was previously called.

true, if cancel was called, otherwise false