How to use the websocket.default function in websocket

To help you get started, we’ve selected a few websocket examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github andrewn / neue-radio / services / speech / src / main.js View on Github external
const main = async () => {
  try {
    const speech = await connectToSpeechd({ autoSpawn: !autoSpawn });
    const broker = createWebSocket();

    log("Connected to WebSocket");

    broker.subscribe(new RegExp("speech/.*"), handleMessage(speech, broker));

    speech.speak("Hello");
  } catch (e) {
    console.log("Error:", e);
  }
};
github andrewn / neue-radio / services / downloader / lib / io / ws / index.js View on Github external
const webSocket = ({ host, downloader }) => {
  const ws = createWebsocket();
  const callback = sendMessage(ws);
  const handler = handleMessage({ host, downloader, callback });

  ws.subscribe(subscribedTopic, handler);
};