mirror of
https://github.com/JKorf/CryptoExchange.Net
synced 2026-02-16 22:23:54 +00:00
wip
This commit is contained in:
parent
ac73fd350b
commit
2b1d10fe02
@ -2,6 +2,7 @@
|
|||||||
using CryptoExchange.Net.Objects;
|
using CryptoExchange.Net.Objects;
|
||||||
using CryptoExchange.Net.Objects.Sockets;
|
using CryptoExchange.Net.Objects.Sockets;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
@ -91,6 +92,28 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
return new MessageRouter(routes.ToArray());
|
return new MessageRouter(routes.ToArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create message matcher
|
||||||
|
/// </summary>
|
||||||
|
public static MessageRouter CreateWithOptionalTopicFilters<T>(IEnumerable<string> typeIdentifiers, IEnumerable<string>? topicFilters, Func<SocketConnection, DateTime, string?, T, CallResult> handler)
|
||||||
|
{
|
||||||
|
var routes = new List<MessageRoute>();
|
||||||
|
foreach (var typeIdentifier in typeIdentifiers)
|
||||||
|
{
|
||||||
|
if (topicFilters?.Count() > 0)
|
||||||
|
{
|
||||||
|
foreach (var filter in topicFilters)
|
||||||
|
routes.Add(new MessageRoute<T>(typeIdentifier, filter, handler));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
routes.Add(new MessageRoute<T>(typeIdentifier, null, handler));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return new MessageRouter(routes.ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create message matcher
|
/// Create message matcher
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@ -635,10 +635,10 @@ namespace CryptoExchange.Net.Sockets
|
|||||||
var subscription = _listeners[i];
|
var subscription = _listeners[i];
|
||||||
foreach (var route in subscription.MessageRouter.Routes)
|
foreach (var route in subscription.MessageRouter.Routes)
|
||||||
{
|
{
|
||||||
if (route.DeserializationType != deserializationType)
|
if (route.TypeIdentifier != typeIdentifier)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (topicFilter == null || route.TopicFilter == null || route.TopicFilter.Contains(topicFilter))
|
if (topicFilter == null || route.TopicFilter == null || route.TopicFilter.Equals(topicFilter, StringComparison.Ordinal))
|
||||||
{
|
{
|
||||||
processed = true;
|
processed = true;
|
||||||
subscription.Handle(this, receiveTime, originalData, result, route);
|
subscription.Handle(this, receiveTime, originalData, result, route);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user