StompleJavaScript消息傳輸框架
Stomple 是一個基于 WebSocket 實現(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
});
主要特點:
1. 可定制以及回調功能
2. 自動收取消息(client.autoReceipt)
3.支持超時處理
4. 事務管理
5. 正確性
評論
圖片
表情
