hyperionjv / bluecove

Automatically exported from code.google.com/p/bluecove
0 stars 0 forks source link

registerService called too soon #4

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
> The description of ServiceRecord.setAttributeValue states:
> 
> "[...] In order for any changes made by this method to be reflected in
> the SDDB, a call must be made to the acceptAndOpen() method of the
> associated notifier to add this ServiceRecord to the SDDB for the first
> time [...]"
> 
> In the implementation however the service is registered in the
> constructor of BluetoothStreamConnectionNotifier instead of in its
> acceptAndOpen() method. This means that changes to the ServiceRecord
> made after creating the notifier but before calling acceptAndOpen for
> the first time, will not be reflected in the SDDB. Since updateRecord is
> unimplemented (for now) this seems unwanted.
>
> Proposed changes:
> 1) remove the registerService call from the constructor
> 2) move it to acceptAndOpen:
> 
> public StreamConnection acceptAndOpen() throws IOException {
>   BluetoothPeer peer =
((LocalDevice)LocalDevice.getLocalDevice()).getBluetoothPeer();
>   if ((handle == 0) && (!closed)) {
>     /* register service */
>     handle = peer.registerService(((ServiceRecordImpl)
serviceRecord).toByteArray());
>   }
>   return new BluetoothConnection(peer.accept(socket));
> }
>
> 3) check if handle != 0 in the close method, before calling
> unregisterService

Original issue reported on code.google.com by paul.tot...@gmail.com on 19 Aug 2006 at 1:28

GoogleCodeExporter commented 9 years ago
in version 1.2.3
acceptAndOpen will update ServiceRecord in SDDB
Also LocalDevice.updateRecord implemented

Original comment by skarzhev...@gmail.com on 8 May 2007 at 8:10