Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.
 
 
 

31 lignes
987 B

  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width,initial-scale=1.0" />
  6. <meta http-equiv="pragma" content="no-cache" />
  7. <meta http-equiv="Cache-Control" content="no-cache, must-revalidate" />
  8. <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT" />
  9. <meta http-equiv="Expires" content="-1" />
  10. <script type="text/javascript" src="signalr.min.js"></script>
  11. </head>
  12. <body>
  13. <h1>接收消息:</h1>
  14. <ul id="msg">
  15. </ul>
  16. <script>
  17. var msgDom = document.getElementById("msg");
  18. const connection = new signalR.HubConnectionBuilder()
  19. .withUrl("http://localhost:5000/JT808MsgHub?access_token=123456")
  20. .build();
  21. connection.on("ReceiveMessage", (tno, message) => {
  22. msgDom.append("<li>" + tno + "=>" + message + "</li>");
  23. });
  24. connection.start().catch(err => console.error(err));
  25. </script>
  26. </body>
  27. </html>