Page 353 - Tasarım Beceri Atölyeleri Öğretmen El Kitabı
P. 353

ws = new WebSocket(“ws://” + ws_host_addr + “/thermometer”, “text.phpoc”);

                          document.getElementById(“ws_state”).innerHTML = “CONNECTING”;
                          ws.onopen = ws_onopen;

                          ws.onclose = ws_onclose;

                          ws.onmessage = ws_onmessage;

                          //ws.binaryType = “arraybuffer”;

                  }
                  else

                          ws.close();

               }

               function ws_onopen()

               {
                  document.getElementById(“ws_state”).innerHTML = “<font color=’blue’>CONNECTED</font>”;

                  document.getElementById(“bt_connect”).innerHTML = “Disconnect”;

                  ws.send(“B\r\n”);

                  update_view(0);

               }

               function ws_onclose()
               {

                  document.getElementById(“ws_state”).innerHTML = “<font color=’gray’>CLOSED</font>”;

                  document.getElementById(“bt_connect”).innerHTML = “Connect”;

                  ws.onopen = null;




                                                                                                                     345
   348   349   350   351   352   353   354   355   356   357   358