The topic subscription for user routing status updates does not successfully get removed from the type map.
If you subscribe to for example v2.users.{some-guid}.routingStatus
, when you add the subscription on line 118
}
/// <summary>
/// Adds a list of subscriptions to the specified topic. Events received on this topic will be cast to the given type.
/// </summary>
/// <param name="subscriptions">A List of Tuples where the first value is the notification topic to add and the second is the Type that should be used when deserializing the notification</param>
public void AddSubscriptions(List<Tuple<string, Type>> subscriptions) {
var topicList = subscriptions.Select(s => new ChannelTopic(s.Item1)).Where(t => (t.Id.ToLowerInvariant() != "channel.metadata") &&
(!t.Id.ToLowerInvariant().StartsWith("v2.system"))).ToList();
_notificationsApi.PostNotificationsChannelSubscriptions(Channel.Id, topicList);
subscriptions.ForEach(s => _typeMap.Add(s.Item1.ToLowerInvariant(), s.Item2));
}
/// <summary>
/// Adds a handler to the specified topic without subscribing. Events received on this topic will be cast to the given type.
/// </summary>
/// <param name="topic">The notification topic to add</param>
/// <param name="type">The <see cref="Type"/> to cast notifications on this topic to</param>
public void AddHandlerNoSubscribe(string topic, Type type)
{
AddHandlersNoSubscribe(new List<Tuple<string, Type>> { new Tuple<string, Type>(topic, type) });
The string key that goes into the type map adds a .ToLowerInvariant()
call to the topic name, resulting in routingstatus
instead of routingStatus
.
This is fine until you go to remove the subscription later. If you try to remove the subscription using the string you subscribed to, it will silently fail on line 152
/// <param name="topic">The notification topic to remove</param>
public void RemoveSubscription(string topic)
{
var subscriptions = _notificationsApi.GetNotificationsChannelSubscriptions(Channel.Id);
var match =
subscriptions.Entities.FirstOrDefault(
e => e.Id.Equals(topic, StringComparison.InvariantCultureIgnoreCase));
if (match == null) return;
subscriptions.Entities.Remove(match);
_notificationsApi.PutNotificationsChannelSubscriptions(Channel.Id, subscriptions.Entities);
_typeMap.Remove(topic);
}
/// <summary>
/// Removes all subscriptions from the channel
/// </summary>
public void RemoveAllSubscriptions()
{
_notificationsApi.DeleteNotificationsChannelSubscriptions(Channel.Id);
_typeMap.Clear();
}
Because the key stored in the private type map is (unbeknown to the user) all lower case, even though the API only accepts routingStatus
with a capital S as the topic string.
Changing line 152
/// <param name="topic">The notification topic to remove</param>
public void RemoveSubscription(string topic)
{
var subscriptions = _notificationsApi.GetNotificationsChannelSubscriptions(Channel.Id);
var match =
subscriptions.Entities.FirstOrDefault(
e => e.Id.Equals(topic, StringComparison.InvariantCultureIgnoreCase));
if (match == null) return;
subscriptions.Entities.Remove(match);
_notificationsApi.PutNotificationsChannelSubscriptions(Channel.Id, subscriptions.Entities);
_typeMap.Remove(topic);
}
/// <summary>
/// Removes all subscriptions from the channel
/// </summary>
public void RemoveAllSubscriptions()
{
_notificationsApi.DeleteNotificationsChannelSubscriptions(Channel.Id);
_typeMap.Clear();
}
to be _typeMap.Remove(topic.ToLowerInvariant());
worked for me.
Hi,
This appears to be related to a recent switch in our code generator tooling. I'll have a release of this ready for the next release of the SDK.
1 Like
Confirmed, release 145.0.1 contains this fix.
Thanks so much!
1 Like
system
Closed
June 25, 2022, 1:12pm
5
This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.