hpfeeds操作
2016-12-15 16:41
399 查看
原文章地址:点击打开链接
正常安装使用hpfeeds的步骤如下git clone https://github.com/rep/hpfeeds/ cd hpfeeds python setup.py build python setup.py install
安装成功后,会出现下面几个文件夹。
![](http://img.mottoin.com/wp-content/uploads/2016/08/1-22.jpg)
appsuport:hpfeeds支持的一些蜜罐的应用程序
broker:服务器功能程序集,包括增加用户,服务器运行,查看所有用户信息等
build:一些编译环境
cli:用户程序
example:例程
lib:支持库
使用时先打开broker,运行其中的add_user.py添加用户信息:
![](http://img.mottoin.com/wp-content/uploads/2016/08/2-23.jpg)
根据提示信息,我们添加用户test,密码123456,拥有发布频道1,2,无订阅频道
![](http://img.mottoin.com/wp-content/uploads/2016/08/3-17.jpg)
再添加用户custom,密码123456,拥有订阅频道1,2,无发布频道
![](http://img.mottoin.com/wp-content/uploads/2016/08/4-13.jpg)
现在使用dump_users.py查看刚才创建的用户
![](http://img.mottoin.com/wp-content/uploads/2016/08/5-10.jpg)
如图所示,这里应经可以查看到刚才我们新建的用户了。
接下来,我们打开服务器feedbroker.py
![](http://img.mottoin.com/wp-content/uploads/2016/08/6-10.jpg)
再开启一个新的进程运行cli文件夹里的用户程序hpfeeds-client
先开启订阅者custom,使用1频道
![](http://img.mottoin.com/wp-content/uploads/2016/08/7-8.jpg)
此时,服务器端显示用户登录成功
![](http://img.mottoin.com/wp-content/uploads/2016/08/8-5.jpg)
我们再打开一个新的进程,以发布者test,使用1频道发布“helloworld”
![](http://img.mottoin.com/wp-content/uploads/2016/08/9-4.jpg)
我们可以看到发布者一旦发布完消息后,立即退出进程,并不确认消息是否收到
这时,服务器显示test登录成功
![](http://img.mottoin.com/wp-content/uploads/2016/08/10-4.jpg)
于此同时,订阅者custom成功接收到消息
![](http://img.mottoin.com/wp-content/uploads/2016/08/11-6.jpg)
到此,一次完整的发送、接收消息的流程就走完了。
通过这一过程,我们发现,频道与用户分离,发送和订阅者身份平等,只需订阅者实时监听,发送者可以即时发送即时撤出。
这里是对于hpfeeds协议的简单介绍,下一部分我会从代码的角度进一步分析该协议,并适当对于协议功能进行添加。
相关文章推荐
- 浅谈JavaScript的自动垃圾收集机制
- 样式优先级
- extjs分页
- javascript学习——constructor、prototype、_proto_的区别
- css制作简单的导航栏
- 一个可以选择时分秒的web前端插件
- ArrayBuffer:类型化数组
- javascript-动画
- 「八面玲珑的 Node.js」- Node 地下铁第三期广州站线下沙龙总结
- nodejs搭建web服务教程
- JQuery easyui Datagrid 分页事件
- jquery 等待3秒钟执行函数
- javascript学习之数组(11)—— 数组 创建及使用
- JSP指令
- Html 两个DIV并排的问题
- js实现默认值参数
- react native 带索引的城市列表
- 222. Count Complete Tree Nodes
- js错误捕获
- Array.prototype.splice方法重写