1

i need to give statistic about my publisher app like how many subscribers are there?

i cant seen to get that information from the redis server

i already tried to find in the 'ServiceStack.Redis.RedisSubscription'

i found this:

        var channel = ConfigurationManager.AppSettings["redis_channel"];
        var _redisClient = new RedisClient("localhost", 6379);
        var subscription = _redisClient.CreateSubscription();
        //subscription.SubscribeToChannels(channel);
        var subscription_count = (int)subscription.SubscriptionCount

but it returning 0 every time.

any ideas?

edit: i found this http://redis.io/commands/client-list but steel need some help on how to use it thanks : )

Doron Eli
  • 71
  • 1
  • 9

1 Answers1

1

i got it!

if anyone need that's i did:

var redis_ip = ConfigurationManager.AppSettings["redis_server_ip"];
        var redis_port = ConfigurationManager.AppSettings["redis_server_port"];
        int redis_port_int = 0;
        if (!int.TryParse(redis_port, out redis_port_int))
        {
            redis_port_int = 6739;
        }
        RedisNativeClient rnClient = new RedisNativeClient(redis_ip, redis_port_int);
        var clientlist_byte = rnClient.ClientList();
        var clientlist_string = Encoding.UTF8.GetString(clientlist_byte);
        var clientamount_double = clientlist_string.Split("\n".ToCharArray()).Length;
        var clientlist_int = (clientamount_double/2) - 1;
        return clientlist_int;

the '-1' is to remove my selt from the count, the /2 it's because after the split i get a doubled amount

Doron Eli
  • 71
  • 1
  • 9