StompleJavaScript消息传输框架

联合创作 · 2023-09-22 15:55

Stomple 是一个基于 WebSocket 实现了 Stomp 消息传输框架协议的 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. 正确性

浏览 8
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报
评论
图片
表情
推荐
点赞
评论
收藏
分享

手机扫一扫分享

编辑
举报