Ejemplo n.º 1
0
        protected void Dispose()
        {
            if (session != null)
            {
                session.Disconnect();
                session.Dispose();
            }

            if (bluetoothClient != null)
            {
                bluetoothClient.Dispose();
            }
        }
Ejemplo n.º 2
0
        protected void SendFileMethod()
        {
            try
            {
                bluetoothClient = new BluetoothClient();

                BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.ObexObjectPush);

                bluetoothClient.Connect(remoteEndPoint);

                session = new ObexClientSession(bluetoothClient.GetStream(), UInt16.MaxValue);
                session.Connect();

                session.PutFile(filePath);

                session.Disconnect();
                session.Dispose();

                bluetoothClient.Dispose();
            }
            catch (PlatformNotSupportedException ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.BT_NoBluetooth);
                Logger.Write(ex);
            }
            catch (ObexResponseException ex)
            {
                ErrorLog.AddError(ErrorType.Failure, Strings.BT_ConnectionRefused);
                Logger.Write(ex);

                if (bluetoothClient != null)
                {
                    bluetoothClient.Dispose();
                }
            }
        }