jmesnil / stomp-websocket

Stomp client for Web browsers and node.js apps
http://jmesnil.net/stomp-websocket/doc/
Apache License 2.0
1.43k stars 587 forks source link

over is not exported #117

Open xenoterracide opened 9 years ago

xenoterracide commented 9 years ago
    var SockJS = require( 'sockjs-client' );
    var sock = new SockJS( SocketUri );
    var Stomp = require( 'stompjs' );
    return Stomp.over( sock );

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 have over documented and exported so that it's easier to find and use. I initially thought that the API had changed since version 0.3.

rfox90 commented 9 years ago
  exports.overTCP = overTCP;

  exports.overWS = overWS;

Are exported. I guess its to provide more explictness when handling a nodejs based client?

Catechacha commented 7 years ago

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

Polve commented 7 years ago

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

Catechacha commented 7 years ago

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); }); });

Polve commented 7 years ago

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