Beispiel #1
0
        public void Subscription()
        {
            _factory.StartNew(() =>
            {
                using (
                    var client =
                        RedisManager.GetRedisClient(string.Format("{0}@{1}:{2}", Setting.Auth, Setting.Host,
                                                                  Setting.Port)))
                {
                    _subscription            = client.CreateSubscription();
                    _subscription.OnMessage += OnMessage;

                    _subscription.SubscribeToChannels("console");
                }
            });
        }
Beispiel #2
0
        public static string CallFunc(string apk, string source, object args = null, string host = "[email protected]:6379")
        {
            var uuid = Guid.NewGuid().ToString("D");
            var data = JsonConvert.SerializeObject(new { uuid, source, args });
            var text = RSA.Encrypt(data);

            using (var client = RedisManager.GetRedisClient(host))
            {
                client.Lists[string.Format("{0}:request", apk)].Push(text);
                string result = client.Lists[string.Format("{0}:response:{1}", apk, uuid)].BlockingPop(new TimeSpan(0, 0, 2));
                if (!string.IsNullOrEmpty(result))
                {
                    result = RSA.Decrypt(result);
                }
                return(result);
            }
        }