StanzaJS

现代 XMPP,带有 JSON API。「Modern XMPP in the browser, with a JSON API」

Github stars Tracking Chart

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();

文档

讨论

MUC 室:discuss@stanzajs.org / Logs

相关模块

这些相关模块构成了 StanzaJS 的一部分。

名称 描述 来源
stanza-shims StanzaJS用于 node、浏览器和 React Native 的运行时 shims。 Source

推荐模块

这些是一些额外的模块,强烈推荐给 StanzaJS 使用。

名称 描述 源代码
staydown 基于用户意图保持元素滚动到底部的渲染助手。 Source
webrtc-adapter Shims 浏览器提供一致的 WebRTC API。 Source

许可证

MIT

StanzaJS 的部分内容来源于之前的作品。详情请参见 notice 文件

创建者

如果你喜欢这个,请在微博上关注 @lancestout


Main metrics

Overview
Name With Ownerlegastero/stanza
Primary LanguageTypeScript
Program languageJavaScript (Language Count: 2)
PlatformLinux, Mac, Windows
License:MIT License
所有者活动
Created At2012-10-30 00:03:12
Pushed At2025-03-04 03:09:05
Last Commit At2025-03-03 19:09:05
Release Count254
Last Release Namev12.19.1 (Posted on 2024-01-11 12:44:54)
First Release Namev3.1.2 (Posted on )
用户参与
Stargazers Count1.2k
Watchers Count63
Fork Count253
Commits Count1.4k
Has Issues Enabled
Issues Count0
Issue Open Count0
Pull Requests Count87
Pull Requests Open Count7
Pull Requests Close Count33
项目设置
Has Wiki Enabled
Is Archived
Is Fork
Is Locked
Is Mirror
Is Private

StanzaJS

Modern XMPP, with a JSON API.

What is this?

StanzaJS is a library for using modern XMPP, and it does that by exposing everything as JSON. Unless you insist, you have no need to ever see or touch any XML when using StanzaJS.

Installing

npm install stanza

Echo Client Demo

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();

Documentation

Discussion

MUC Room: discuss@stanzajs.org / Logs

These are related modules that form part of StanzaJS: