📄 bluetoothserver.java
字号:
import java.io.IOException;
import java.io.PrintStream;
import javax.bluetooth.LocalDevice;
import javax.bluetooth.ServiceRecord;
import javax.bluetooth.UUID;
import javax.microedition.io.Connector;
import javax.microedition.io.StreamConnection;
import javax.microedition.io.StreamConnectionNotifier;
final class BluetoothServer
implements Runnable
{
private static final UUID BRC_SERVER = new UUID("7771FDC2FDDF4c9bAFFC98BCD91BF93B", false);
private LocalDevice localDevice;
private StreamConnectionNotifier notifier;
private ServiceRecord record;
private BluetoothRemoteControl parent;
private boolean isClosed;
private Thread accepterThread;
BluetoothServer(BluetoothRemoteControl paramBluetoothRemoteControl)
{
this.parent = paramBluetoothRemoteControl;
this.accepterThread = new Thread(this);
this.accepterThread.start();
}
public void run()
{
boolean bool = false;
try
{
this.localDevice = LocalDevice.getLocalDevice();
if (!(this.localDevice.setDiscoverable(10390323)));
StringBuffer localStringBuffer = new StringBuffer("btspp://");
localStringBuffer.append("localhost").append(':');
localStringBuffer.append(BRC_SERVER.toString());
localStringBuffer.append(";name=Bluetooth RC Server");
localStringBuffer.append(";authorize=false");
this.notifier = ((StreamConnectionNotifier)Connector.open(localStringBuffer.toString()));
this.record = this.localDevice.getRecord(this.notifier);
bool = true;
}
catch (Exception localException)
{
System.err.println("Can't initialize bluetooth: " + localException);
}
this.parent.completeInitialization(bool);
if (!(bool))
return;
while (!(this.isClosed))
{
label141: StreamConnection localStreamConnection = null;
try
{
localStreamConnection = this.notifier.acceptAndOpen();
}
catch (IOException localIOException)
{
break label141:
}
this.parent.connectServerSuccess(localStreamConnection);
}
}
void destroy()
{
this.isClosed = true;
if (this.notifier != null)
try
{
this.notifier.close();
}
catch (IOException localIOException)
{
}
try
{
this.accepterThread.join();
}
catch (InterruptedException localInterruptedException)
{
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -