leancloud / Js Realtime Sdk
Licence: mit
LeanCloud Realtime Message JavaScript SDK
Stars: ✭ 193
Programming Languages
javascript
184084 projects - #8 most used programming language
Projects that are alternatives of or similar to Js Realtime Sdk
onchat-web
A simple, beautiful, mobile-first instant messaging progressive web application.
Stars: ✭ 138 (-28.5%)
Mutual labels: realtime, im
space-cloud
Open source Firebase + Heroku to develop, scale and secure serverless apps on Kubernetes
Stars: ✭ 3,405 (+1664.25%)
Mutual labels: realtime, baas
Space Cloud
Open source Firebase + Heroku to develop, scale and secure serverless apps on Kubernetes
Stars: ✭ 3,323 (+1621.76%)
Mutual labels: baas, realtime
Unityrtc
基于webrtc的unity多人游戏实时语音(A Unity Demo for Impl Real-time Game Voice Among Mutiplayers Based On WEBRTC)
Stars: ✭ 74 (-61.66%)
Mutual labels: sdk, realtime
Flamelink
JavaScript SDK for integrating with Flamelink CMS 🔥
Stars: ✭ 186 (-3.63%)
Mutual labels: sdk
Universe push
[飞享]-基于t-io的即时通讯系统,采用服务化框架Dubbo实现应用服务化,使用SpringBoot构建应用,可做信令服务器使用,支持docker,k8s快速部署。Android版本支持私聊,群聊,支持voip通话,支持语音,短视频,图片,位置发送。web客户端基于vue框架,基于websocket协议,基于json的自定义文本协议实现消息解析,支持与android客户端实现消息互通。实现一端发布,多端同步消息,支持android端与web端音视频通话。[公测地址](https://chat.comsince.cn)
Stars: ✭ 189 (-2.07%)
Mutual labels: im
Speechtotext Websockets Javascript
SDK & Sample to do speech recognition using websockets in Javascript
Stars: ✭ 191 (-1.04%)
Mutual labels: sdk
Iot Python
Client libraries and samples for connecting to IBM Watson IoT using Python 2.7 and 3.x
Stars: ✭ 183 (-5.18%)
Mutual labels: sdk
LeanCloud JavaScript Realtime SDK
为您的 JavaScript App 接入 LeanCloud 实时通讯服务。
版本说明
遵循 语义化版本。
安装稳定版本:
npm install leancloud-realtime --save
安装测试版本:
npm install [email protected] --save
安装指定版本:
// 安装 v3 版本
npm install [email protected] --save
支持的运行环境
- 浏览器 / WebView
- IE 10+
- Edge latest
- Chrome 45+
- Firefox latest
- iOS 9.3+
- Android 4.4+
- Node.js 4.0+
- 微信小程序/小游戏 latest
- React Native 0.26+
- Electron latest
文档
Demo
插件
package name | 描述 | 版本 | 文档 |
---|---|---|---|
leancloud-realtime-plugin-typed-messages | 富媒体消息 | API docs | |
leancloud-realtime-plugin-groupchat-receipts | 群聊已读回执 | API docs | |
leancloud-realtime-plugin-webrtc | WebRTC 客户端 | API docs |
支持
- 在使用过程中遇到了问题时
- 如果你是商用版用户,请新建一个工单。
- 也可以在 论坛 提问、讨论。
贡献
如果你希望为这个项目贡献代码,请按以下步骤进行:
- Fork 这个项目,clone 到本地
- 在目录中执行
npm install
安装所需 Node.js 依赖包 - 编码,更新测试用例
- 运行
npm test
确保测试全部 pass - 提交改动,请遵循 conversational commit message 风格
- 发起 Pull Request 至 master 分支
项目的目录结构
.
├── demo
├── deploy.sh // 部署 gh-pages 分支
├── release.sh // 部署 dist 分支
├── dist // 打包产出 (dist 分支)
│ ├── core.js // 核心逻辑(不包含运行时)
│ ├── im.js // IM(不包含运行时)
│ ├── im-browser.js // 浏览器用
│ ├── im-weapp.js // 微信小程序用
│ └── im-node.js // node 用
├── proto
│ ├── message-compiled.js // 使用 pbjs 生成的 message 类
│ ├── message.js // ES6 wrapper
│ └── message.proto // proto 原始文件
├── src // 源码
│ └── index.js // 打包入口
├── test // 测试用例
│ ├── browser // 浏览器测试入口
│ └── index.js // 测试入口
└── plugins
├── typed-messages // leancloud-realtime-plugin-typed-messages package
└── webrtc // leancloud-realtime-plugin-webrtc package
Architecture
SDK 分为连接层与应用层两部分,只存在应用层对连接层公开 API 的调用,连接层对开发者不可见。
连接层
-
WebSocketPlus
:封装了 WebSocket。相比 w3 WebSocket,增加了以下特性:- 是一个有限状态机
- 实现了 Node.js EventEmitter 接口
- 超时与自动重连机制
- url 参数支持 Promise 及备用地址
-
Connection
:继承自WebSocketPlus
,增加了与业务相关的功能:- 根据 subprotocol 自动处理发送与接收的消息,应用层发送接收的均是 ProtoBuf Message 类
-
send
接口返回 Promise,在 server 回复后才算 send 成功 - 实现了应用层 ping/pong
应用层
-
Realtime
:开发者使用 SDK 的入口,负责访问 router、创建 connection、创建与管理 clients、创建 messageParser(管理消息类型)、监听 connection 的消息并 dispatch 给对应的 client -
Client
:所有的 clients 共享一个 connection-
IMClient
:对应即时通讯中的「用户」,持有 connection 与 conversations,负责创建管理将收到的消息处理后在对应 conversation 上派发,所有的 IMClients 共享一个 messageParser
-
-
MessageParser
消息解析器,负责将一个 JSON 格式的消息 parse 为对应的 Message 类 -
Conversation
:实现对话相关的操作-
ConversationQuery
:对话查询器
-
-
Messages
-
AVMessage
:接口描述,生成文档用 -
Message
:消息基类 -
TypedMessage
:类型消息基类,继承自Message
-
TextMessage
:文本消息,继承自TypedMessage
- 其他富媒体消息类(
FileMessage
及其子类、LocationMessage
)由于依赖 leancloud-storage,作为另一个独立 package 发布
-
开启调试模式
Node.js
export DEBUG=LC*
浏览器
localStorage.setItem('debug', 'LC*');
Develop Workflow
本地开发
更新 .proto 后请运行
npm run convert-pb
测试
npm run test:node -- --grep KEYWORDS
浏览器测试
npm run test:browser-local
编译
npm run build
持续集成
合并 PR 到 master 分支后持续集成会自动运行 npm build
与 npm run docs
,然后将 dist 目录推送到 dist 分支,将文档与 demo 推送到 gh-pages。
Release Process Workflow
- 遵循 semver 提升
package.json
中的版本号 -
npm run changelog
生成新的changelog.md
,润色之 - Commit
package.json
,changelog.md
- Push to remote
master
branch - 等待持续集成 pass
- 使用 GitHub 基于 dist 分支生成 pre-release 包(for bower)
- Fetch and checkout remote
dist
branch 并确认该提交的内容是即将发布的版本 - npm publish(
npm publish
,需 npm 协作者身份),如果是 pre-release 版本需要带 next tag - 如有更新,在 npm 上发布各个 plugin
Note that the project description data, including the texts, logos, images, and/or trademarks,
for each open source project belongs to its rightful owner.
If you wish to add or remove any projects, please contact us at [email protected].