Stomple - JavaScript消息传输框架


未知
跨平台
JavaScript

软件简介

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. 正确性