Skip to main content

Chat example flow

The example bundle contains React, Svelte, Vanilla, and CDN chat apps using IOSignal 7.2.0. Each has its own local WebSocket server. Start with Vanilla:

cd iosignal_vanilla-chat
npm ci
npm run dev

Open http://localhost:5175 in two tabs. Wait for ready, send a message, and confirm it in the other tab. This app connects to ws://localhost:7779 and subscribes to openchat.

Read vite.config.js for the two development servers and main.js for the client lifecycle:

  1. Create the client and register message/state handlers.
  2. On each ready, subscribe to openchat.
  3. Send only when ready; display received channel messages.
  4. Remove handlers and destroy owned clients when the page or component ends.

on() registers a handler without subscribing. Framework components sharing a client should use the scoped ownership and cleanup described in subscriptions.

The site's public chat is a separate live service, so messages there may reach other visitors. Local tests use only the local servers. For media calls, see the separate WebRTC example.

Example source​