Пример #1
0
 private BthDevice GetConnection(L2CapDataPacket packet)
 {
     lock (_connected)
     {
         return((!_connected.Any() | !_connected.ContainsKey(packet.Handle)) ? null : _connected[packet.Handle]);
     }
 }
Пример #2
0
        /// <summary>
        /// Kill specific connection
        /// </summary>
        /// <param name="Connection"></param>
        public void CloseConnection(Connection Connection)
        {
            try
            {
                if (ConnectionList.Any(wr => wr.Value == Connection))
                {
                    Connection.Close();
                    ConnectionList.Remove(Connection.cIndex);

                    if (WriteLogs)
                    {
                        Logs.WriteLog("black", "Closed Connection with index [{0}] ", Connection.cIndex);
                    }
                }

                InvokeUI.UpdateConnectionsCount(ConnectionList.Count);
            }
            catch (Exception Ex)
            {
                if (WriteDebugLogs)
                {
                    Logs.WriteLog("red", Ex.Message);
                }
            }
        }
Пример #3
0
        /// <summary>
        ///     Returns an existing Bluetooth connection based on an incoming buffer.
        /// </summary>
        /// <param name="lsb">Least significant bit in byte stream.</param>
        /// <param name="msb">Most significant bit in byte stream.</param>
        /// <returns>The Bluetooth connection, null if not found.</returns>
        private BthDevice GetConnection(byte lsb, byte msb)
        {
            var hande = new BthHandle(lsb, msb);

            return((!_connected.Any() | !_connected.ContainsKey(hande)) ? null : _connected[hande]);
        }