Пример #1
0
 public TreeUpdator(Tree.Tree tree, StackExchange.Redis.ISubscriber subscriber)
 {
     _thisSender = Guid.NewGuid().ToString();
     _tree       = tree;
     _subscriber = subscriber;
     _channelMessageSerializer = new JsonSerializer <TreeUpdateChannelMessageData>();
     subscriber.SubscribeAsync(DatabaseSchema.TreeUpdateChannel).ContinueWith(t => t.Result.OnMessage(ProcessItemUpdate), TaskContinuationOptions.LongRunning);
 }
Пример #2
0
        public async Task SubscribeAsync(string key, Action <int, RedisMessage> onMessage)
        {
            await _redisSubscriber.SubscribeAsync(key, (channel, data) =>
            {
                var message = RedisMessage.FromBytes(data, _logger);
                onMessage(0, message);

                _latestMessageId = message.Id;
            });
        }
Пример #3
0
        public async Task SubscribeAsync(string key, Action <int, RedisMessage> onMessage)
        {
            await _redisSubscriber.SubscribeAsync(key, (channel, data) =>
            {
                var message = RedisMessage.FromBytes(data, _trace);
                onMessage(0, message);

                // Save the last message id in just in case redis shuts down
                _latestMessageId = message.Id;
            });
        }