コード例 #1
0
ファイル: PushSubTests.cs プロジェクト: itmanlee/HRedis
        public void Subscribe_Test()
        {
            using (RedisPubSub rsc = new RedisPubSub(ip, port))
            {
                rsc.OnMessage += OnMessage;
                rsc.Subscribe("test");

                Thread.Sleep(10000);
            }
        }
コード例 #2
0
ファイル: PushSubTests.cs プロジェクト: itmanlee/HRedis
        public void UnSubscribe_Test()
        {
            RedisPubSub rsc = new RedisPubSub(ip, port);

            rsc.OnUnSubscribe += (obj) =>
            {
                var reply = obj as object[];

                Debug.WriteLine(reply[0].ToString() + reply[1].ToString() + reply[2].ToString());
            };
            rsc.OnSuccess += (obj) =>
            {
                Debug.WriteLine(obj[0].ToString() + obj[1].ToString() + obj[2].ToString());
            };

            rsc.Subscribe("test");
            Thread.Sleep(1000);
            rsc.UnSubscribe("test");
            rsc.Subscribe("test");
            Thread.Sleep(1000);
            rsc.UnSubscribe("test");
        }
コード例 #3
0
ファイル: ChatHub.cs プロジェクト: Poepon/JK
        public ChatHub(WebSocketConnectionManager webSocketConnectionManager,
                       IHttpContextAccessor httpContextAccess,
                       IOnlineClientManager <ChatChannel> onlineClientManager,
                       IChatAppService chatAppService,
                       JKSession jkSession,
                       IObjectMapper objectMapper,
                       IAppContext appContext,
                       RedisPubSub redisPubSub) :
            base(appContext, onlineClientManager, webSocketConnectionManager)
        {
            this.httpContextAccess = httpContextAccess;

            this.chatAppService = chatAppService;
            AbpSession          = jkSession;
            _objectMapper       = objectMapper;
            _redisPubSub        = redisPubSub;
            _redisPubSub.Subscribe(appContext.LocalHostName);
        }
コード例 #4
0
        private static void Main(string[] args)
        {
            //using (RedisClient client = new RedisClient("127.0.0.1", 6381))
            //{
            //    Console.WriteLine(client.Set("key", "value"));
            //    Console.WriteLine(client.Get("key"));
            //}

            //new RedisClient(new RedisConfig()
            //{
            //    Host = "127.0.0.1",
            //    Port = 6379,
            //    PassWord = "******",
            //    ReceiveTimeout = 0,
            //    SendTimeout = 0
            //});

            //PoolRedisClient prc = new PoolRedisClient("127.0.0.1", 6381);
            //var info = prc.Single.Info;


            //Console.WriteLine((1 == get1() || 1 == get2()));
            //PoolRedisClient prc = new PoolRedisClient("127.0.0.1", 6381);
            //using (var client = prc.GetClient())
            //{
            //    Console.WriteLine(client.Get("key"));
            //}


            //Console.ReadLine();

            RedisPubSub client = new RedisPubSub("127.0.0.1", 6381);

            client.OnUnSubscribe += (obj) => Console.WriteLine();
            client.OnMessage      = (sender, arcgs) => Console.WriteLine(arcgs);
            client.OnError        = (Exception) => Console.WriteLine(Exception.Message);
            client.Subscribe("bar");
            Console.ReadLine();
        }