Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
ws.callback = function(message, value) {
switch (message) {
case Client.connect:
trace("socket connect\n");
break;
case Client.handshake:
trace("websocket handshake success\n");
this.write(JSON.stringify({count: 1, toggle: true}));
break;
case Client.receive:
trace(`websocket message received: ${value}\n`);
value = JSON.parse(value);
value.count += 1;
value.toggle = !value.toggle;
value.random = Math.round(Math.random() * 1000);
this.write(JSON.stringify(value));
break;