integration.js 1020 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. $(document).ready(function(){
  2. var url = "ws://localhost:61623";
  3. var login = "admin";
  4. var passcode = "password"
  5. var destination = "/topic/chat.general";
  6. $("#server_url").text(url);
  7. $("#queue_name").text(destination);
  8. var client = Stomp.client(url);
  9. debug = function(str) {
  10. $("#debug").append(str + "\n");
  11. };
  12. client.debug = debug;
  13. // the client is notified when it is connected to the server.
  14. var onconnect = function(frame) {
  15. debug("connected to Stomp");
  16. client.subscribe(destination,
  17. function(frame) {
  18. client.unsubscribe(destination);
  19. client.disconnect();
  20. },
  21. { receipt: 1234 });
  22. };
  23. client.onerror = function(frame) {
  24. debug("connected to Stomp");
  25. };
  26. client.ondisconnect = function() {
  27. debug("disconnected from Stomp");
  28. };
  29. client.onreceipt = function() {
  30. debug("receipt from Stomp");
  31. client.send(destination, {foo: 1}, "test")
  32. };
  33. client.connect(login, passcode, onconnect);
  34. return false;
  35. });