Java Reference
In-Depth Information
private void processRequest(StreamConnection conn) {
DataInputStream dis = null;
String pref = null;
String height = null;
String contact = null;
try {
dis = conn.openDataInputStream();
pref = dis.readUTF();
height = dis.readUTF( );
contact = dis.readUTF();
dis.close();
conn.close();
} catch (IOException e) {} // Ignore
if (!mLastContact.equals(contact)) {
mLastContact = contact;
if (pref.equals(seekPref) && height.equals(seekHeight))
mDisplay.callSerially(new ShowCandidate(contact));
}
}
class ShowCandidate implements Runnable {
Display disp = null;
String contact = null;
public ShowCandidate(String cont) {
contact = cont;
}
public void run() {
mDateContact.setText(contact );
}
}
}
In the server code (the run() method), the LocalDevice is first set to discoverable, then a
StreamConnectionNotifier is created called mServerNotifier . The server thread then waits for
incoming requests by calling acceptAndOpen() . The incoming connection is read for the sex,
height, and e-mail address of the nearby dating candidate. If the items match those you are
looking for, the GUI will be updated with the date's e-mail address.
Infrared Communications and OBEX
Unlike the Bluetooth radio-based technology, communications via infrared requires a line-of-sight
connection between the senders and receivers. This is because infrared devices communicate
via light beams that must be aimed (roughly) at one another. Similar to Bluetooth devices,
Search WWH ::




Custom Search