internal static bool TryHandle(GenesysMessage message, ISubject <object> subject, IGenesysTopicSubscriptions topics)
        {
            var topicName = message.TopicName();

            if (topics.Items.ContainsKey(topicName))
            {
                var topicType = topics.Items[topicName];
                if (topicType.IsGenericType && topicType.GetGenericTypeDefinition() == typeof(NotificationData <>))
                {
                    var data = JsonSerializer.Deserialize(message.Raw, topicType, _options.Value);
                    if (data != null)
                    {
                        subject.OnNext(data);
                    }
                }
                else
                {
                    var body = message.EventBody();
                    var data = JsonSerializer.Deserialize(body.Value.GetRawText(), topics.Items[topicName], _options.Value);
                    if (data != null)
                    {
                        subject.OnNext(data);
                    }
                }
                return(true);
            }
            return(false);
        }
 internal static bool TryHandle(GenesysMessage message, ISubject <PongResponse> subject)
 {
     if (message.TopicName() == ChannelMetadata && message.Message()?.ToLower() == "pong")
     {
         subject.OnNext(new PongResponse());
         return(true);
     }
     return(false);
 }
 internal static bool TryHandle(GenesysMessage message, ISubject <SocketClosingResponse> subject)
 {
     if (message.TopicName() == SocketClosing)
     {
         subject.OnNext(new SocketClosingResponse()
         {
             Date = DateTime.UtcNow
         });
         return(true);
     }
     return(false);
 }