dk.itu.smds.torusman
Class BTSender

java.lang.Object
  extended by java.lang.Thread
      extended by dk.itu.smds.torusman.BTSender
All Implemented Interfaces:
java.lang.Runnable, javax.bluetooth.DiscoveryListener

public class BTSender
extends java.lang.Thread
implements javax.bluetooth.DiscoveryListener

The class BTSender handles actions that need to be taken to be able to send information of the current player to all the other players on the bluetooth network.


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
 
Fields inherited from interface javax.bluetooth.DiscoveryListener
INQUIRY_COMPLETED, INQUIRY_ERROR, INQUIRY_TERMINATED, SERVICE_SEARCH_COMPLETED, SERVICE_SEARCH_DEVICE_NOT_REACHABLE, SERVICE_SEARCH_ERROR, SERVICE_SEARCH_NO_RECORDS, SERVICE_SEARCH_TERMINATED
 
Constructor Summary
BTSender()
          Instantiates a new BT sender.
 
Method Summary
 void deviceDiscovered(javax.bluetooth.RemoteDevice R, javax.bluetooth.DeviceClass arg1)
          Prints out that a device has been discovered and searches for the relevant service on the discovery agent.
 java.lang.String getURL(int i)
          Gets the URL of the index from the device list.
 void inquiryCompleted(int arg0)
          Prints out that the inquiry has been completed.
 void run()
          Sleeps the thread for 5 seconds to let the game get up and running and then gets the agent and inquires.
 void sendMove(ManData m, byte x, byte y)
          Send the move to all the other players in the vector list.
 void sendScore(byte manId, byte teamId, int points)
          Sends the score to all the other players in the vector list.
 void servicesDiscovered(int arg0, javax.bluetooth.ServiceRecord[] servRecord)
          Add the remote bluetooth device to the device list so that packages can later be sent and received.
 void serviceSearchCompleted(int arg0, int arg1)
          Prints out that the search for services has been completed.
 
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

BTSender

public BTSender()
Instantiates a new BT sender.

Method Detail

sendScore

public void sendScore(byte manId,
                      byte teamId,
                      int points)
Sends the score to all the other players in the vector list.

Parameters:
manId - the man id
teamId - the team id
points - the points

sendMove

public void sendMove(ManData m,
                     byte x,
                     byte y)
Send the move to all the other players in the vector list.

Parameters:
m - the ManData
x - the new x
y - the new y

deviceDiscovered

public void deviceDiscovered(javax.bluetooth.RemoteDevice R,
                             javax.bluetooth.DeviceClass arg1)
Prints out that a device has been discovered and searches for the relevant service on the discovery agent.

Specified by:
deviceDiscovered in interface javax.bluetooth.DiscoveryListener
Parameters:
R - the remote device
arg1 - the class of the device
See Also:
DiscoveryListener.deviceDiscovered(javax.bluetooth.RemoteDevice, javax.bluetooth.DeviceClass)

inquiryCompleted

public void inquiryCompleted(int arg0)
Prints out that the inquiry has been completed.

Specified by:
inquiryCompleted in interface javax.bluetooth.DiscoveryListener
See Also:
DiscoveryListener.inquiryCompleted(int)

serviceSearchCompleted

public void serviceSearchCompleted(int arg0,
                                   int arg1)
Prints out that the search for services has been completed.

Specified by:
serviceSearchCompleted in interface javax.bluetooth.DiscoveryListener
See Also:
DiscoveryListener.serviceSearchCompleted(int, int)

servicesDiscovered

public void servicesDiscovered(int arg0,
                               javax.bluetooth.ServiceRecord[] servRecord)
Add the remote bluetooth device to the device list so that packages can later be sent and received.

Specified by:
servicesDiscovered in interface javax.bluetooth.DiscoveryListener
Parameters:
servRecord - the list of services on a specific device
See Also:
DiscoveryListener.servicesDiscovered(int, javax.bluetooth.ServiceRecord[])

getURL

public java.lang.String getURL(int i)
Gets the URL of the index from the device list.

Parameters:
i - the index
Returns:
the URL

run

public void run()
Sleeps the thread for 5 seconds to let the game get up and running and then gets the agent and inquires.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread
See Also:
Thread.run()