StanzaJS
浏览器中的现代 XMPP,带有 JSON API。
这是什么?
StanzaJS 是一个使用现代 XMPP 的 JavaScript/TypeScript 库,它通过将所有的东西以 JSON 的形式暴露出来。除非你坚持,否则在使用 StanzaJS 时,你不需要看到或接触任何 XML。
安装
npm install stanza
Echo 客户端演示
import * as XMPP from 'stanza'; const client = XMPP.createClient({ jid: 'echobot@example.com', password: 'hunter2', // If you have a .well-known/host-meta.json file for your // domain, the connection transport config can be skipped. transports: { websocket: 'wss://example.com:5281/xmpp-websocket', bosh: 'https://example.com:5281/http-bind' } }); client.on('session:started', () => { client.getRoster(); client.sendPresence(); }); client.on('chat', msg => { client.sendMessage({ to: msg.from, body: 'You sent: ' + msg.body }); }); client.connect();
文档
- API Reference
- JXT: JSON/XML Translation
- Supported XEP Formats
- Creating Plugins
- Using with React Native
- Using PubSub
- Using Stream Management
讨论
MUC 室:discuss@stanzajs.org / Logs
相关模块
这些相关模块构成了 StanzaJS 的一部分。
名称 | 描述 | 来源 |
---|---|---|
stanza-shims | StanzaJS用于 node、浏览器和 React Native 的运行时 shims。 | Source |
推荐模块
这些是一些额外的模块,强烈推荐给 StanzaJS 使用。
名称 | 描述 | 源代码 |
---|---|---|
staydown | 基于用户意图保持元素滚动到底部的渲染助手。 | Source |
webrtc-adapter | Shims 浏览器提供一致的 WebRTC API。 | Source |
许可证
StanzaJS 的部分内容来源于之前的作品。详情请参见 notice 文件。
创建者
如果你喜欢这个,请在微博上关注 @lancestout。