amp.js 621 B

12345678910111213141516171819202122232425
  1. var stompClient = null;
  2. function connect() {
  3. var socket = new SockJS('http://localhost:8081/amp/websocket');
  4. stompClient = Stomp.over(socket);
  5. stompClient.connect({}, function (frame) {
  6. console.log('Connected: ' + frame);
  7. stompClient.subscribe('/channel/entity-events', function (msg) {
  8. var msgJ = JSON.parse(msg.body);
  9. console.log(msgJ);
  10. });
  11. });
  12. }
  13. function disconnect() {
  14. if (stompClient !== null) {
  15. stompClient.disconnect();
  16. }
  17. setConnected(false);
  18. console.log("Disconnected");
  19. }
  20. $(document).ready(function() {
  21. connect();
  22. });