Exemplo n.º 1
0
        private string[] Send(string responseCommand, string key, Tuple <string, string>[] parameter, params string[] message)
        {
            var response = new YateResponse();
            var eventKey = GetKey(responseCommand, key);

            if (!_eventQueue.TryAdd(eventKey, response))
            {
                throw new ArgumentException("this command is currently pending");
            }
            var command = Command(message);

            if (parameter != null)
            {
                command += ':' + String.Join(":", parameter.Select(x => _serializer.Encode(x)));
            }
            Send(command);
            return(response.GetResponse());
        }
Exemplo n.º 2
0
        private async Task <string[]> SendAsync(string responseCommand, string key, CancellationToken cancellationToken, Tuple <string, string>[] parameter, params string[] message)
        {
            var response = new YateResponse();
            var eventKey = GetKey(responseCommand, key);

            if (!_eventQueue.TryAdd(eventKey, response))
            {
                throw new ArgumentException("this command is currently pending");
            }
            var command = Command(message);

            if (parameter != null)
            {
                command += ':' + String.Join(":", parameter.Select(x => _serializer.Encode(x)));
            }
            await SendAsync(command, cancellationToken).ConfigureAwait(false);

            return(await response.GetResponseAsync(cancellationToken).ConfigureAwait(false));
        }