Advertisement
Guest User

Untitled

a guest
Mar 19th, 2019
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.60 KB | None | 0 0
  1. function openWebSocket() {
  2.  
  3. console.log("OpenWEbsocket!");
  4. //printReadyState();
  5.  
  6. if ("WebSocket" in window) {
  7.  
  8. var ip = IoDataHelper.readDataModelValue(VlxDevConstants.EXT_BROWSER_IP);
  9. // for testing
  10.  
  11.  
  12. }
  13. }if (!vproduction) {
  14. if (ip == "") {
  15. ip = "192.168.0.124";
  16.  
  17. var port = IoDataHelper.readDataModelValue(VlxDevConstants.EXT_BROWSER_PORT);
  18.  
  19. wsUri = "ws://" + ip + ":" + port + "/";
  20.  
  21. console.log("--------------------------------------------------------");
  22. console.log("IP ADDRESS FOR SOCKET:" + wsUri);
  23. console.log("--------------------------------------------------------");
  24.  
  25.  
  26. if (((vlxWebSocket != null) && (vlxWebSocket.readyState == vlxWebSocket.OPEN)) ||
  27. ((vlxWebSocket != null) && (vlxWebSocket.readyState == vlxWebSocket.CLOSED)) || (vlxWebSocket==null))
  28. {
  29. console.log("Socket exists and is idle");
  30. vlxWebSocket = null;
  31.  
  32. vlxWebSocket = new WebSocket(wsUri);
  33. vlxWebSocket.binaryType = "arraybuffer";
  34. vlxWebSocket.onmessage = onMessage;
  35. vlxWebSocket.onopen = onOpen;
  36. vlxWebSocket.onclose = onClose;
  37. vlxWebSocket.onerror = onError;
  38.  
  39. }
  40. else {
  41. return;
  42. }
  43.  
  44.  
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement