ไลบรารีนี้ให้บริการไคลเอนต์ WebSocket สำหรับเว็บเบราว์เซอร์และแอปพลิเคชัน Node.js
กรุณาเยี่ยมชม https://stomp-js.github.io/ สำหรับคำแนะนำ, คำถามที่พบบ่อยและเอกสาร API
ไลบรารีนี้ช่วยให้คุณเชื่อมต่อกับนายหน้าซื้อขายหลักทรัพย์ผ่าน WebSocket ห้องสมุดนี้รองรับข้อมูลจำเพาะ Stomp ที่สมบูรณ์รวมถึงตัวแปรโปรโตคอลปัจจุบันทั้งหมด โบรกเกอร์การส่งข้อความยอดนิยมส่วนใหญ่รองรับการกระทืบและกระทืบผ่าน WebSockets นอกกรอบหรือใช้ปลั๊กอิน
<!--
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 ถูกโฮสต์เป็นหน้า GitHub สำหรับตระกูล STOMPJS ของห้องสมุด คุณสามารถตรงไปที่ 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 มีคำจำกัดความ TypeScript ดังนั้นจึงไม่จำเป็นต้องติดตั้งแยกต่างหาก
กรุณาเยี่ยมชมบันทึกการเปลี่ยนแปลง
หากคุณต้องการเข้าใจรหัสพัฒนาหรือมีส่วนร่วม กรุณาเยี่ยมชมวิธีการมีส่วนร่วม
ใบอนุญาต - Apache -2.0