Open xenoterracide opened 9 years ago
exports.overTCP = overTCP;
exports.overWS = overWS;
Are exported. I guess its to provide more explictness when handling a nodejs based client?
I want to use websocket with SockJs and Stomp client-side, and Java server-side, in a Spring-boot web application. I have installed with npm sockjs-client and stompjs. My client-side code is:
var SockJS = require('sockjs-client');
var Stomp = require("stompjs");
var socket = new SockJS('/webSocketEndPoint');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
stompClient.subscribe('/topic/notification', function (notificationBody) {
alert(JSON.parse(notificationBody.body).content);
});
})
The methods over and subscribe are not working, so the websocket i want to build is not working. IntelliJ say me "Unresolved function or method over" and "Unresolved function or method subscribe ". I've included in my package.json stompjs and sockjs-client (correct version). The initial requires not makes me problem, but i'm not able to run this script..Someone can help me?! Thanks a lot
I'm using it without problems, this is an extract of the code:
const Stomp = require('webstomp-client') const WebSocketClient = require('ws') var ws = new WebSocketClient(stompEndpoint) var stompClient = Stomp.over(ws, options)
EDIT: sorry, I got the wrong project: this is the code for the new version of the library (this one is discontinued), that you can find here: https://github.com/JSteunou/webstomp-client
The problem was only IntelliJ..Now i have another problem: Stomp's over method works, but connect method is not working..
socket = new SockJS('/webSocketEndPoint');
stompClient = Stomp.over(socket);
stompClient.connect({}, function (frame) {
console.log('Connected: ' + frame);
stompClient.subscribe('/topic/notification', function (notificationBody) {
showNotification(angular.fromJson(notificationBody.body).content);
});
});
This is not a support forum... Anyway you can find a real world usage example here: https://github.com/melis-wallet/melis-api-js/blob/master/src/cm.js
so although this works my IDE (IntelliJ Idea) didn't think
over
was a method, and didn't see it documented on npmjs. It'd be nice to haveover
documented and exported so that it's easier to find and use. I initially thought that the API had changed since version 0.3.