Anders and Briegel in Python
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.

30 lines
704B

  1. define(["message"], function(message){
  2. return {
  3. connect: function(update){
  4. var ws = new WebSocket("ws://localhost:5000");
  5. ws.onopen = function(evt)
  6. {
  7. message.serverMessage("Connected to server.");
  8. };
  9. ws.onerror = function(err)
  10. {
  11. message.serverMessage("Could not connect to server.");
  12. };
  13. ws.onmessage = function (evt)
  14. {
  15. update(JSON.parse(evt.data));
  16. };
  17. ws.onclose = function(evt)
  18. {
  19. message.serverMessage("Connection to server lost. <a href='#' onclick='javascript:connect_to_server()'>Reconnect</a>.");
  20. };
  21. }
  22. };
  23. }
  24. );