You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
898 B

5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
5 months ago
  1. const ws = new WebSocket(`ws://${window.location.host}`);
  2. ws.onopen = () => {
  3. console.log("Connected to server");
  4. // ws.send("Hello from client!");
  5. };
  6. ws.onmessage = event => {
  7. console.log(`Message from server: ${event.data}`);
  8. };
  9. ws.onclose = () => {
  10. console.log("Disconnected from server");
  11. };
  12. $("#startRecord").on("click", () => {
  13. $.ajax({
  14. type: "POST",
  15. url: "/api/measurement-task/start-measurement",
  16. data: JSON.stringify({}),
  17. contentType: "application/json",
  18. success: res => {
  19. console.log("Success", res);
  20. },
  21. error: err => {
  22. console.error("Error", err);
  23. },
  24. });
  25. });
  26. $("#endRecord").on("click", () => {
  27. $.ajax({
  28. type: "POST",
  29. url: "/api/measurement-task/stop-measurement",
  30. data: JSON.stringify({}),
  31. contentType: "application/json",
  32. success: res => {
  33. console.log("Success", res);
  34. },
  35. error: err => {
  36. console.error("Error", err);
  37. },
  38. });
  39. });