Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
The logic is simple, a local stomp client connect to server over websocket, then get data, modify data save data etc. What I confuse is, I've searched Stomp on cpan, all modules about Stomp does not support WS, The Mojo::ua support WS (and async which why I prefer it), but doesn't support Stomp Protocol directly. Before I dig into Stomp protocol, is there a decent way to combine Mojo::ua and Stomp(Like Net::Stomp)? Thanks.var url = "ws://localhost:61614/stomp"; var client = Stomp.client(url); function afterConnect(roomid) { btn.addEventListener('click', function () { var msg = input.value; client.send(roomid, {}, msg); }, false); } function createConnect(roomid, uid) { client.connect(headers, function (error) { if (error.command == "ERROR") { console.error(error.headers.message); } else { afterConnect(roomid); client.subscribe(uid, function (msg) { var body = msg.body; if (msg.headers['content-type'] == 'application/json') { body = JSON.parse(msg.body) } }); } }); } ...... ......
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: how Mojo::ua work with Net::Stomp
by Corion (Patriarch) on Oct 14, 2023 at 09:37 UTC | |
by Anonymous Monk on Oct 14, 2023 at 10:07 UTC |