10 Star 47 Fork 10

10km / webredis

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
BSD-2-Clause

webredis

介绍

基于websocket+redis+nodejs实现web端消息推送

webredis是一个在node.js下运行的web服务,用于支持web端实现redis消息订阅发布。

安装

cd webredis
# 安装依赖库
npm install
# 或cnpm install

使用

系统要求: node.js

运行node.js 服务

cd webredis
node webredis.js

显示帮助信息node webredis.js -h

Usage: node.js webredis.js [OPTION...]

选项:
  --help, -h  show the messae                                             [布尔]

  --version   显示版本号                                                  [布尔]

  --port, -p  webredis web port                                 [默认值: "16379"]

  --rhost     redis host                                   [默认值: "localhost"]

  --rport     redis port                                          [默认值: 6379]

  --rauth     redis password                                        [默认值: ""]

  --rdb       redis database                                         [默认值: 0]

运行演示页面

  1. 进入test文件夹,打开index.html。
  2. 可以再网页进行一系列redis的操作:订阅、取消订阅、发送信息

服务端redis请求接口(event)

subscribe (订阅频道)

参数 类型 说明
channels string or string[] 频道名,或频道列表

unsubscribe (取消订阅)

参数 类型 说明
channels string or string[] 频道名,或频道列表

pubish (发布消息)

参数 类型 说明
channel string 目标频道名
message string 要发布的消息

服务端推送接口

message (订阅消息)

参数 类型 说明
message json 收到的消息

message消息字段说明

参数 类型 说明
channel string 订阅频道名
data string 收到的消息数据

ack (响应消息)

参数 类型 说明
ack json 服务端redis请求接口的返回响应消息

ack消息字段说明

参数 类型 说明
success boolean redis调用请求是否成功
request string redis调用请求名,such as 'publish','subscribe','unsubscribe'
reply any redis调用的返回值,类型由redis调用的返回值决定
respone string 收到的响应数据
BSD 2-Clause License Copyright (c) 2019, 10km All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: * Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

简介

基于websocket+redis+nodejs实现消息推送 展开 收起
JavaScript 等 3 种语言
BSD-2-Clause
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
JavaScript
1
https://gitee.com/l0km/webredis.git
git@gitee.com:l0km/webredis.git
l0km
webredis
webredis
master

搜索帮助