npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

socket-client-stomp

v1.2.1

Published

基于 Socket-client,stompjs 实现的 socket 方法类封装

Downloads

5

Readme

基于 Socket-client,stompjs 实现的 socket 方法类封装

使用方法


npm install socket-client-stomp -D

import Socket from 'socket-client-stomp'

// 创建类 --- 连接地址后面必须拼接上系统的用户accessToken
const newSocket = new Socket('http://localhost:8081')

// 初始化连接
newSocket.init(headers, successCallback, errorCallBack)

// 关闭连接
newSocket.close()

// 订阅消息
url:
  1. 订阅广播消息 -- 如/topic/topicMessage
  2. 订阅部门消息 -- 如/topic/dept/ + 环境 + '/' + 部门ID
  3. 订阅区划消息 -- 如/topic/group/ + 环境 + '/' + 区划ID
  4. 用户模式    -- 如/user/queue/message/ + 环境
  5. 用户模式错误信息  -- 如/user/queue/errors/ + 环境
newSocket.subscribeInfo(url,callback)


// 发送广播消息
newSocket.sendBroadcastInfo(messageInfo, url = '/app/topicMessage')

// 发送用户消息
newSocket.sendUserInfo(messageInfo, url = '/app/multiple')

// 发生部门消息
newSocket.sendDeptInfo(messageInfo, url = '/app/dept')


// 发送区划消息
newSocket.sendGroupInfo(messageInfo, url = '/app/group')

API

| 方法名称 | 方法功能说明 | 参数 | 参数类型 | 参数说明 | | :---------------: | :----------------------: | :-------------------------------------: | :-------------------------------: | :----------------------------------------------------------------------------------------------------------------------------------------------------------: | | init | 初始化 socket 并建立连接 | headers, successCallback, errorCallBack | headers:Object, 回调函数 | headers 对象中必须传用户名称 name | | close | 关闭连接 | 无 | 无 | 无 | | subscribeInfo | 订阅消息 | url,callback | url: string ,callback:function | url: 1.订阅广播消息 -- 如/topic/topicMessage 2. 订阅部门消息 -- 如/topic/dept/ + 环境 + '/' + 部门 ID3.用户模式 -- 如/user/queue/message/ + 环境 | | sendBroadcastInfo | 发送广播消息 | url,messageInfo | url: string ,messageInfo:object | url 默认为'/app/topicMessage' | | sendUserInfo | 发送用户消息 | url,messageInfo | url: string ,messageInfo:object | url 默认为'/app/multiple' | | sendDeptInfo | 发送部门消息 | url,messageInfo | url: string ,messageInfo:object | url 默认为'/app/dept' | | sendGroupInfo | 发送区划消息 | url,messageInfo | url: string ,messageInfo:object | url 默认为'/app/group' |

请求头 headers 参数说明

| 参数名称 | 参数说明 | 参数类型 | 是否必须 | | :---------: | :----------------: | :------: | :------: | | accessToken | 系统用户登陆 token | string | true |

信息体 MessageInfo 参数说明

| 参数名称 | 参数说明 | 参数类型 | 是否必须 | | :-----------: | :--------------------------------------------------------------------: | :------: | :------: | | data | 消息内容 | string | true | | env | 接收者环境,web 端(admin),指挥大屏(command),手机端(mobile),多个逗号隔开 | string | true | | messageSource | 消息来源,web 端(admin),指挥大屏(command),手机端(mobile) | string | true | | messageType | 消息类型, websocket 消息('1'),系统消息('2'),mq 同步消息('3') | string | true | | messageName | 消息名称 | string | false | | receiver | 接收者名称,多个逗号隔开 | string | false | | bizType | 业务类型 | string | false | | refJson | 关联的内容 json 字符串 | string | false |