Exemple #1
0
        internal async Task <T> SendAsync <T>(WsRequest request)
        {
            if (_connection == null)
            {
                throw new InvalidOperationException("Does not connect to WebSocket stream");
            }
            await _connection.SendAsync(request).Stay();

            var response = await _observable.Cast <WsResponse>().FirstAsync(w => $"api:{request.Body.Id}" == w?.Type);

            if (response.Body is WsRestResponseObject obj)
            {
                return(obj.Res.ToObject <T>());
            }
            return(default);