wechat-stomp

1.0.8 • Public • Published

小程序如何使用 stomp

安装 npm i wechat-stomp

1. 初始化连接 建议在 app.js

wxStompClient 是全局的一个 stompClient

wxStompClient.connect(socketConfig, stompConnectConfig)

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

import {StompBehavior, wxStompClient} from 'wechat-stomp'

Page({
    behaviors: [StompBehavior]
})

系统主要功能

  • 支持使用behaviors方式使用stomp的API
  • 支持web socket连接断开自动重连
  • 支持主题订阅后断开重新连接后自动恢复订阅功能

Package Sidebar

Install

npm i wechat-stomp

Weekly Downloads

0

Version

1.0.8

License

ISC

Unpacked Size

32.5 kB

Total Files

8

Last publish

Collaborators

  • han1396735592