websocket.js 557 B

123456789101112131415161718192021222324
  1. self.importScripts("helper.js");
  2. // var socketURL = "ws://192.168.11.66:9101";
  3. var socketURL = "ws://14.215.128.98:14102"
  4. // socketURL = "ws://127.0.0.1:8081"
  5. var ws = new WebSocket(socketURL);
  6. ws.binaryType = 'arraybuffer';
  7. ws.addEventListener('open', function(event) {
  8. console.log("发送配置帧");
  9. ws.send(ConfigChannel("RK3923C1201900139"));
  10. });
  11. ws.addEventListener('message', function(event) {
  12. //var objData = {type:0, data:input};
  13. var input = new Uint8Array(event.data);
  14. if (input[0] == 0xff) {
  15. } else {
  16. self.postMessage(input);
  17. }
  18. });