https://github.com/han1396735592/wechat-stomp
微信小程序stomp客户端
https://github.com/han1396735592/wechat-stomp
stomp stomp-client websocket wechat
Last synced: 7 months ago
JSON representation
微信小程序stomp客户端
- Host: GitHub
- URL: https://github.com/han1396735592/wechat-stomp
- Owner: han1396735592
- Created: 2022-04-11T09:26:11.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2022-04-12T01:27:26.000Z (about 4 years ago)
- Last Synced: 2025-02-22T19:02:29.196Z (over 1 year ago)
- Topics: stomp, stomp-client, websocket, wechat
- Language: JavaScript
- Homepage:
- Size: 10.7 KB
- Stars: 5
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# 小程序如何使用 stomp
## 安装 `npm i wechat-stomp`
## 1. 初始化连接 建议在 app.js
> ### `wxStompClient` 是全局的一个 stompClient
> ### `wxStompClient.connect(socketConfig, stompConnectConfig)`
>
```js
import {wxStompClient} from 'wechat-stomp'
wxStompClient.connect({
url: 'ws://localhost:8080/stomp/websocket',
header: {
'content-type': 'application/json',
},
}, {})
```
### 2.使用 behavior 的方式
> ### 订阅消息 this._stompSubscribe(destination, callback)
> ### 解除订阅 this._stompUnsubscribe(destination)
> ### 发送消息 this._stompSend()
>
```js
import {StompBehavior, wxStompClient} from 'wechat-stomp'
Page({
behaviors: [StompBehavior]
})
```
### 系统主要功能
- 支持使用`behaviors`方式使用stomp的API
- 支持`web socket`连接断开自动重连
- 支持主题订阅后断开重新连接后自动恢复订阅功能