mswjs / socket.io-binding

Connection wrapper for mocking Socket.IO with MSW.
1 stars 1 forks source link

Support the broadcasting API #5

Open kettanaito opened 3 months ago

kettanaito commented 3 months ago

MSW ws now supports broadcasting so we should propagate that support to the SocketIO binding.

  1. Look up what API SocketIO uses for broadcasting;
  2. Implement that API using .broadcast() and .broadcastExcept() methods on the MSW event handler.
kettanaito commented 2 months ago

Alas, the binding depends on the Interceptors, and there's no broadcasting concept there.

kettanaito commented 2 months ago

I think the binding should accept the entire WebSocket link. That way, it can also use the broadcasting capabilities of MSW relying on its own client manager.

import { ws } from 'msw'
import { bind } from '@mswjs/socket.io-binding'

const api = bind(ws.link('*'))

api.on('connection', (args) => {})