Example #1
0
		public static List<FSAgentCallbac> Get(ClientInfo clientInfo)
		{
			if (IsConnectionLost)
			{
				Thread.Sleep(TimeSpan.FromSeconds(1));
				var result = new List<FSAgentCallbac>();
				var fsAgentCallbac = new FSAgentCallbac()
				{
					IsConnectionLost = IsConnectionLost
				};
				result.Add(fsAgentCallbac);
				return result;
			}

			lock (FSAgentCallbacCashes)
			{
				var result = new List<FSAgentCallbac>();
				var safeCopy = FSAgentCallbacCashes.ToList();
				foreach (var callbackResultSaver in safeCopy)
				{
					if (callbackResultSaver.Index > clientInfo.CallbackIndex)
					{
						result.Add(callbackResultSaver.FSAgentCallbac);
					}
				}
				if (safeCopy.Count > 0)
				{
					clientInfo.CallbackIndex = safeCopy.Max(x => x.Index);
				}
				return result;
			}
		}
Example #2
0
		public static void Add(FSAgentCallbac fsAgentCallbac)
		{
			lock (FSAgentCallbacCashes)
			{
				FSAgentCallbacCashes.RemoveAll(x => (DateTime.Now - x.DateTime) > TimeSpan.FromMinutes(1));

				LastIndex++;
				var callbackResultSaver = new FSAgentCallbacCash()
				{
					FSAgentCallbac = fsAgentCallbac,
					Index = LastIndex,
					DateTime = DateTime.Now
				};
				FSAgentCallbacCashes.Add(callbackResultSaver);
			}
			ClientsManager.ClientInfos.ForEach(x => x.PollWaitEvent.Set());
		}