public override void OnStatus(string message) { base.OnStatus(message); switch (message) { case BluetoothClient.COULD_NOT_CREATE_SOCKET: throw new BluetoothException("The client could not create a socket"); case BluetoothClient.COULD_NOT_CONNECT: throw new BluetoothException("The client could not connect to the server"); case BluetoothClient.CONNECTION_LOST: client.OnConnectionLost(); break; case BluetoothClient.DISCONNECTED: client.OnDisconnected(); break; } string[] tokens = message.Split('.'); if (tokens[0] == "client" && tokens[1] == "connected") { DeviceInfoEventArgs e = new DeviceInfoEventArgs(); e.Device = Bluetooth.GetDevice(tokens[2]); client.OnConnected(e); } }
public override void OnStatus(string status) { base.OnStatus(status); ServerStateChangedEventArgs e = new ServerStateChangedEventArgs(); switch (status) { case COULD_NOT_LISTEN: throw new BluetoothException("Server could not start listening"); case LISTENING: e.State = ServerState.LISTENING; server.OnServerStateChanged(e); break; case NOT_LISTENING: e.State = ServerState.NOT_LISTENING; server.OnServerStateChanged(e); break; case STOPPED: e.State = ServerState.STOPPED; server.OnServerStateChanged(e); break; } string[] tokens = status.Split('.'); DeviceInfoEventArgs e2 = new DeviceInfoEventArgs(); if (tokens[0] == "server" && tokens.Length >= 3) { e2.Device = Bluetooth.GetDevice(tokens[2]); if (tokens[1] == "connected") { server.OnClientConntected(e2); } else if (tokens[1] == "disconnected") { server.OnClientDisconnected(e2); } } }