1 Star 0 Fork 2

hjh2096 / iotserver-netty

forked from qianbo0423 / iotserver-netty 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
readRedis.js 2.16 KB
一键复制 编辑 原始数据 按行查看 历史
qianbo0423 提交于 2019-06-02 15:33 . modify remove the file nginx
var redis = require("redis");
var client = redis.createClient(6379, "192.168.1.222");
var client1 = redis.createClient(6379, "192.168.1.222");
client1.on('connect', function () {
client1.subscribe("draw");
});
client1.on("message", function (channel, message) {
console.log(typeof (message));
var obj = JSON.parse(message);
console.log("普通订阅接收到来自" + channel + "的信息:" + obj.session);
if (message == "quit") {
client1.unsubscribe("draw");
console.log("普通订阅操作已经取消");
//client2.quite();
}
});
/*
var client2 = redis.createClient("6379", "192.168.1.222");
client2.on('connect', function () {
client2.psubscribe("draw*");
});
client2.on("pmessage", function (p, channel, message) {
console.log("批量订阅接收到来自" + channel + "的信息:" + message);
if (message == "quit") {
client2.punsubscribe("draw*");
console.log("批量订阅操作已经取消");
//client2.quite();
}
});
*/
/*
function getRedisData() {
//客户端连接redis成功后执行回调
client.on("ready", function () {
//订阅消息
client.subscribe("chat");
client.subscribe("chat1");
console.log("订阅成功。。。");
});
client.on("error", function (error) {
console.log("Redis Error " + error);
});
//监听订阅成功事件
client.on("subscribe", function (channel, count) {
console.log("client subscribed to " + channel + "," + count + "total subscriptions");
});
//收到消息后执行回调,message是redis发布的消息
client.on("message", function (channel, message) {
console.log("我接收到信息了" + message);
//dealWithMsg(message);
});
//监听取消订阅事件
client.on("unsubscribe", function (channel, count) {
console.log("client unsubscribed from" + channel + ", " + count + " total subscriptions")
});
}
function dealWithMsg(message) {
//按照message查询内容
client1.zscore("key", message, function (err, reply) {
console.log(message + "的内容是:" + reply);
});
}
getRedisData();
*/
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Java
1
https://gitee.com/hjh2096/iotserver-netty.git
git@gitee.com:hjh2096/iotserver-netty.git
hjh2096
iotserver-netty
iotserver-netty
master

搜索帮助

344bd9b3 5694891 D2dac590 5694891