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.

пре 8 година
пре 8 година
пре 8 година
пре 8 година
пре 8 година
1234567891011121314151617181920212223242526
  1. var websocket = {};
  2. websocket.connect = function(update){
  3. var ws = new WebSocket("ws://localhost:5000");
  4. ws.onopen = function(evt)
  5. {
  6. gui.serverMessage("Connected to server.");
  7. };
  8. ws.onerror = function(err)
  9. {
  10. gui.serverMessage("Could not connect to server.");
  11. };
  12. ws.onmessage = function (evt)
  13. {
  14. update(JSON.parse(evt.data));
  15. };
  16. ws.onclose = function(evt)
  17. {
  18. gui.serverMessage("Connection to server lost. <a href='#' onclick='javascript:websocket.connect()'>Reconnect</a>.");
  19. };
  20. };