示例#1
0
        public PubSub(Action<PubSub> ready)
        {
            subbed = new JsDictionary<string, Action<string>>();

            var redis = Global.Require<NodeLibraries.Redis.Redis>("redis");
            redis.DebugMode = false;
            subClient = redis.CreateClient(6379, Constants.RedisIP);
            pubClient = redis.CreateClient(6379, Constants.RedisIP);
            subClient.On("subscribe", (string channel, int count) => Logger.Log("subscribed: " + channel + " " + count,LogLevel.Information));
            subClient.On("unsubscribe", (string channel, int count) => Logger.Log("unsubscribed: " + channel + " " + count, LogLevel.Information));

            subClient.On("message",
                         (string channel, string message) => {
                             if (subbed[channel] != null)
                                 subbed[channel](message);
                         });
            subClient.On("ready",
                         () => {
                             sready = true;
                             if (sready && pready)
                                 ready(this);
                         });
            pubClient.On("ready",
                         () => {
                             pready = true;
                             if (sready && pready)
                                 ready(this);
                         });
        }
示例#2
0
        public QueueWatcher(string queue, Action<string, UserLogicModel, string, object> callback)
        {
            Channel = queue;
            Callback = callback;

            var redis = Global.Require<Redis>("redis");

            client1 = redis.CreateClient(6379, Constants.RedisIP);

            Cycle(queue);
        }
示例#3
0
 public QueuePusher(string pusher)
 {
     var redis = Global.Require<Redis>("redis");
     Channel = pusher;
     client1 = redis.CreateClient(6379, IPs.RedisIP);
 }