Beispiel #1
0
        private AniDBRequest QueueCommand(string command, IEnumerable <KeyValuePair <string, string> > parValues)
        {
            if (SessionKey != "")
            {
                parValues = parValues.ToDictionary(p => p.Key, p => p.Value);
            }

            ((Dictionary <string, string>)parValues).Add("s", SessionKey);

            var request = new AniDBRequest(command, parValues);

            if (_sentRequests.ContainsKey(request.Tag))
            {
                throw new ArgumentException("A request with that tag has already been sent");
            }

            _sendBucket.Input(request);

            return(request);
        }
Beispiel #2
0
        private void SendPacket(AniDBRequest request)
        {
            //In theory this should never fail (GUIDs are supposed to be globally unique)
            if (!_sentRequests.TryAdd(request.Tag, request))
            {
                request.OnResponse(null);
                return;
            }

            byte[] requestBytes = request.ToByteArray(_encoding);

            _udpClient.Send(requestBytes, requestBytes.Count());
            Debug.Print(requestBytes.ToString());

            request.Timeout.Elapsed += (o, a) =>
            {
                AniDBRequest r;
                _sentRequests.TryRemove(request.Tag, out r);
            };
            request.Timeout.Interval = Timeout;
            request.Timeout.Enabled  = true;
        }
Beispiel #3
0
		private AniDBRequest QueueCommand(string command, IEnumerable<KeyValuePair<string, string>> parValues)
		{
			if (SessionKey != "")
				parValues = parValues.ToDictionary(p => p.Key, p => p.Value);
			
			((Dictionary<string, string>) parValues).Add("s", SessionKey);

			var request = new AniDBRequest(command, parValues);

			if(_sentRequests.ContainsKey(request.Tag))
				throw new ArgumentException("A request with that tag has already been sent");

			_sendBucket.Input(request);

			return request;
		}
Beispiel #4
0
		private void SendPacket(AniDBRequest request)
		{
			//In theory this should never fail (GUIDs are supposed to be globally unique)
			if (!_sentRequests.TryAdd(request.Tag, request))
			{
				request.OnResponse(null);
				return;
			}

			byte[] requestBytes = request.ToByteArray(_encoding);

			_udpClient.Send(requestBytes, requestBytes.Count());
			Debug.Print(requestBytes.ToString());

			request.Timeout.Elapsed += (o, a) =>
				                           {
					                           AniDBRequest r;
					                           _sentRequests.TryRemove(request.Tag, out r);
				                           };
			request.Timeout.Interval = Timeout;
			request.Timeout.Enabled = true;
		}