コード例 #1
0
 public static int HookFunc(string source, string host = "[email protected]:6379")
 {
     using (var client = RedisManager.GetRedisClient(host))
     {
         return(client.PublishMessage("hooks", RSA.Encrypt(source)));
     }
 }
コード例 #2
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");
                }
            });
        }
コード例 #3
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);
            }
        }