使用wafer2解决方案时,信道服务始终依赖于腾讯内部提供的信道服务系统,对腾讯过于依赖,可控性差,于是使用nodejs按照wafer2-node-sdk与wafer2-client-sdk的接口封装独立的信道服务系统。
git clone https://github.com/miwoy/weapp-node-tunnel
// index.js global.CONFIG = { serverHost: "127.0.0.1", // 信道服务器地址 port: 80, // 信道服务端口 protocol: "ws://" // 信道服务协议 }
npm install
npm start
// 修改sdk.config.js serverHost: 'localhost:5757', tunnelServerUrl: 'http://127.0.0.1:8080', tunnelSignatureKey: 'abcdefghijkl',
待补充...
接口协议
/**
* interface
* getTunnel(postUrl) -> tunnelId & tunnelUrl
* connect(tunnelUrl) -> websocket
* emit message -> on message
* post message -> post message
*
* websocket.on
* error 错误
* close 关闭
* connect 已连接
* ping ping/pong
* message 消息
*/
MIT License
Copyright (c) 2018 Miwoes
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.