stompjs
1.0.0
该库为Web浏览器和Node.js应用程序提供了WebSocket客户端的踩踏。
请访问https://stomp-js.github.io/获取指南,常见问题解答和API文档。
该库允许您通过WebSocket连接到Stomp Broker。该库支持完整的踩踏规格,包括所有当前协议变体。大多数受欢迎的消息经纪人都在开箱即用的Websockets或使用插件上支持Stomp和Stomp。
<!--
JSPM Generator Import Map
Edit URL: https://generator.jspm.io/#U2NgYGBkDM0rySzJSU1hcCguyc8t0AeTWcUO5noGega6SakliaYAYTzJAykA
-->
< script type =" importmap " >
{
"imports" : {
"@stomp/stompjs" : "https://ga.jspm.io/npm:@stomp/[email protected]/esm6/index.js"
}
}
</ script >
<!-- ES Module Shims: Import maps polyfill for modules browsers without import maps support (all except Chrome 89+) -->
< script
async
src =" https://ga.jspm.io/npm:[email protected]/dist/es-module-shims.js "
crossorigin =" anonymous "
> </ script >
< script type =" module " >
import { Client } from '@stomp/stompjs' ;
const client = new Client ( {
brokerURL : 'ws://localhost:15674/ws' ,
onConnect : ( ) => {
client . subscribe ( '/topic/test01' , message =>
console . log ( `Received: ${ message . body } ` )
) ;
client . publish ( { destination : '/topic/test01' , body : 'First Message' } ) ;
} ,
} ) ;
client . activate ( ) ;
</ script >
$ npm install @stomp/stompjs ws
import { Client } from '@stomp/stompjs' ;
import { WebSocket } from 'ws' ;
Object . assign ( global , { WebSocket } ) ;
const client = new Client ( {
brokerURL : 'ws://localhost:15674/ws' ,
onConnect : ( ) => {
client . subscribe ( '/topic/test01' , message =>
console . log ( `Received: ${ message . body } ` )
) ;
client . publish ( { destination : '/topic/test01' , body : 'First Message' } ) ;
} ,
} ) ;
client . activate ( ) ;
API文档作为Stompjs图书馆家族的GitHub页面托管。您可以直接前往https://stomp-js.github.io/api-docs/latest/
该库带有详细的用法说明。请通过使用说明找到它。在https://stomp-js.github.io/上查看其他指南。
有非常详细的API文档,您应该从https://stomp-js.github.io/api-docs/latest/classes/client.html开始。
如果您使用此库的较旧版本,则需要对代码进行更改。前往升级。
https://github.com/stomp-js/rx-stomp基于此库,并将此库提供的全部功能揭示为RXJS可观察。
NPM软件包包含打字稿定义,因此无需单独安装。
请访问更改日志。
如果您想了解代码,开发或贡献。请访问如何贡献。
许可证-Apache -2.0