Example #1
0
 private BthDevice GetConnection(L2CapDataPacket packet)
 {
     lock (_connected)
     {
         return((!_connected.Any() | !_connected.ContainsKey(packet.Handle)) ? null : _connected[packet.Handle]);
     }
 }
Example #2
0
        /// <summary>
        /// 通过连接名称获得Host信息
        /// </summary>
        /// <param name="ConnectionName"></param>
        /// <returns></returns>
        public MongoServerAddress GetMongoSvrAddrByConnectionName(String ConnectionName)
        {
            MongoServerAddress mongosrvAddr = null;

            if (ConnectionList.ContainsKey(ConnectionName))
            {
                mongosrvAddr = new MongoServerAddress(ConnectionList[ConnectionName].Host, ConnectionList[ConnectionName].Port);
            }
            return(mongosrvAddr);
        }
Example #3
0
        public async Task Init(string characterName)
        {
            if (ConnectionList.TryGetValue(UserName, out var details))
            {
                await details.ClientProxy.SendAsync("DisconnectDuplicateConnection");

                var startWait = DateTime.Now;
                while (ConnectionList.ContainsKey(UserName))
                {
                    await Task.Delay(100);

                    if (DateTime.Now > startWait.AddSeconds(3))
                    {
                        await Clients.Caller.SendAsync("FailLoginDueToExistingConnection");

                        return;
                    }
                }
            }
            var characterID = DataService.GetCharacter(UserName, characterName).ID;

            GameEngine.Current.InputQueue.Enqueue(dbContext =>
            {
                var character           = dbContext.PlayerCharacters.Find(characterID);
                character.MovementAngle = 0;
                character.MovementForce = 0;
            });
            ConnectionDetails = new ConnectionDetails()
            {
                CharacterName = characterName,
                CharacterID   = characterID,
                UserName      = UserName,
                ConnectionID  = Context.ConnectionId,
                ClientProxy   = Clients.Caller
            };
            SendInitialUpdate();

            ConnectionList.AddOrUpdate(UserName, ConnectionDetails, (k, v) => ConnectionDetails);
            await Clients.All.SendAsync("CharacterConnected", characterName);
        }
Example #4
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]);
        }