Ejemplo n.º 1
0
    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();
      }
    }
Ejemplo n.º 2
0
    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();
    }
Ejemplo n.º 3
0
 public abstract Task ConnectAsync(DeviceInfo RacerDevice);