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