1 Star 0 Fork 10

梦想天空 / rpc for nodejs

forked from feimat / rpc for nodejs 
Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
This repository doesn't specify license. Please pay attention to the specific project description and its upstream code dependency when using it.
Clone or Download
contribute
Sync branch
Cancel
Notice: Creating folder will generate an empty file .keep, because not support in Git
Loading...
README

nodejs实现的rpc(基于koa实现),以网页聊天室为示例。 支持所有pc与手机浏览器 支持所有app内部webview 支持自动重连 支持心跳处理 支持双向rpc与单向通信 支持协程功能。欢迎使用与反馈bug。技术交流qq群:339711102 项目地址 https://git.oschina.net/feimat/qiyi

使用教程: git clone https://git.oschina.net/feimat/qiyi.git cd qiyi/ npm install 然后 node index.js

网页 http://localhost:3001/ 即可访问聊天。

发送rpc请求(这里演示客户端发送,服务器端发送参考示例):

var rpc_client = new rpcClient('http://‘+host);
var data = "hello";
rpc_client.emit('chat', data,{
                  "success": function(response) {
                      console.log(response)
                  },
                  "timeout_time": 4000,
                  "timeout_cb": function() {
                  },
                  "error": function() {
                  }
              });

接受rpc请求(这里演示服务器端接收,客户端接受参考示例):

// next:沿用koa个人感觉没必要暴露
// ctx: 对端socket上下文信息
// message: 接收到的消息
// cb: 回调函数 cb(data) 表示返回data给发送端
app.io.route('chat', function* (next, ctx, message,cb) {
     cb("server recive "+message+" and start send to other people ");
     var send_suc_num = 0; // 成功收到消息的聊天成员
     for (var socket in all_sockets) {
        // 服务器端向客户端发送rpc
        app.emit(socket, 'chat', message,{
                  "success": function(response) {
                      console.log("suc recive num:"+send_suc_num);
                  },
                  "timeout_time": 4000,
                  "timeout_cb": function() {
                  },
                  "error": function() {
                  }
              });
     }  

Empty file

About

nodejs实现的rpc(基于koa实现),以网页聊天室为示例。 支持所有pc与手机浏览器 支持所有app内部webview 支持自动重连 支持心跳处理 支持双向rpc与单向通信 支持协程功能。 expand collapse
NodeJS
Cancel

Releases

No release

Contributors

All

Activities

Load More
can not load any more
NodeJS
1
https://gitee.com/xuexi1126/qiyi.git
git@gitee.com:xuexi1126/qiyi.git
xuexi1126
qiyi
rpc for nodejs
master

Search