ch.aplu.bluetooth
Class BluetoothServer

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

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
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
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

BluetoothServer

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

Parameters:
listener - the BtListener to get connnect information

BluetoothServer

public BluetoothServer(BtListener listener)
Method Detail

run

public void run()
For internal use only.

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

cancel

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.


close

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.


isCanceled

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

Returns:
true, if cancel was called, otherwise false