Example #1
0
		public static PollResult Get(ClientInfo clientInfo)
		{
			lock (CallbackResultItems)
			{
				var result = new PollResult();
				result.CallbackIndex = CallbackManager.Index;
				foreach (var callbackResultItem in CallbackResultItems)
				{
					if (callbackResultItem.CallbackResult.Index > clientInfo.CallbackIndex)
					{
						if (callbackResultItem.ClientType.HasValue && (callbackResultItem.ClientType.Value & clientInfo.ClientCredentials.ClientType) == ClientType.None)
							continue;
						if (callbackResultItem.ClientUID.HasValue && callbackResultItem.ClientUID.Value != clientInfo.UID)
							continue;
						if (callbackResultItem.CallbackResult.GKProgressCallback != null && callbackResultItem.CallbackResult.GKProgressCallback.IsCanceled)
							continue;
						if (!AutomationHelper.CheckLayoutFilter(callbackResultItem.CallbackResult.AutomationCallbackResult, clientInfo.LayoutUID))
							continue;
						if (callbackResultItem.CallbackResult.AutomationCallbackResult != null && callbackResultItem.CallbackResult.AutomationCallbackResult.Data is GlobalVariableCallBackData)
						{
							var data = callbackResultItem.CallbackResult.AutomationCallbackResult.Data as GlobalVariableCallBackData;
							if (data.InitialClientUID.HasValue && data.InitialClientUID.Value == clientInfo.UID)
								continue;
						}
						if (clientInfo.CallbackIndex < callbackResultItem.CallbackResult.Index)
							clientInfo.CallbackIndex = callbackResultItem.CallbackResult.Index;
						result.CallbackResults.Add(callbackResultItem.CallbackResult);
					}
				}
				return result;
			}
		}
Example #2
0
		public static bool Add(ClientCredentials clientCredentials)
		{
			if (ClientInfos.Any(x => x.UID == clientCredentials.ClientUID))
				return false;

			var result = true;
			var existingClientInfo = ClientInfos.FirstOrDefault(x => x.ClientCredentials.UniqueId == clientCredentials.UniqueId);
			if (existingClientInfo != null)
			{
				Remove(existingClientInfo.UID);
				result = false;
			}

			var clientInfo = new ClientInfo();
			clientInfo.UID = clientCredentials.ClientUID;
			clientInfo.ClientCredentials = clientCredentials;
			clientInfo.CallbackIndex = CallbackManager.Index;
			ClientInfos.Add(clientInfo);

			Notifier.AddClient(clientCredentials);
			return result;
		}