override public async Task ConnectAsync(DeviceInfo RacerDevice) { try { //First connect to the bluetooth device... HostName deviceHost = new HostName(RacerDevice.HostName); //If the socket is already in use, dispose of it if (streamSocket != null || dataWriter != null) CloseConnection(); //Create a new socket streamSocket = new StreamSocket(); await streamSocket.ConnectAsync(deviceHost, "1"); dataWriter = new DataWriter(streamSocket.OutputStream); RaisePropertyChanged("IsConnected"); } catch(Exception ex) { //Dispose and Destroy the StreamSocket and DataWriter CloseConnection(); //Not sure what to do here yet, just pass it along throw; } finally { //Regardless of what happened, let the view know that the connection state likely changed. RaiseRacerConnectionStateChanged(); } }
public override async Task ConnectAsync(DeviceInfo RacerDevice) { racerDevice = RacerDevice; string connectMessage = string.Format("Connecting to:\n{0}", racerDevice.ToString()); Debug.WriteLine(connectMessage); isConnected = true; RaiseRacerConnectionStateChanged(); }
public abstract Task ConnectAsync(DeviceInfo RacerDevice);