StompleJavaScript消息傳輸框架
Stomple 是一個(gè)基于 WebSocket 實(shí)現(xiàn)了 Stomp 消息傳輸框架協(xié)議的 JavaScript 包。
示例代碼:
var client = Stomple.create_client({
url : "ws://localhost:61614/stomp",
destination : "jms.topic.chat",
login : "guest",
passcode : "guest"
});
client.subscribe({
success: function(frame) {//called if subscribe succeeds within timeout-period
//subscribe succeeded... do something
},
failure: function(spec) {//called if subscribe fails or times out
console.log(spec.reason);
},
handler: function(msg) {//called when a message arrived ('this' is scope - see below)
this.received = msg.body;//"this" is "someObject"
},
scope: someObject
});
主要特點(diǎn):
1. 可定制以及回調(diào)功能
2. 自動(dòng)收取消息(client.autoReceipt)
3.支持超時(shí)處理
4. 事務(wù)管理
5. 正確性
評論
圖片
表情
