Making A Socket Tester - rogue-wavelength/rogue-wavelength GitHub Wiki
Testing Sockets
Open up node in your project folder (where socket.io-client has been npm installed)
$ node
Require the socket.io client and then open up a connection to the socket.io server:
> const io = require('socket.io-client')
> const socket = io(`${serverName}`)
You can then create arbitrary listeners and emit arbitrary events from node. An arbitrary listener is in the form of socket.on(${eventName}
, callbackFn) and an arbitrary event is in the form of socket.emit(${eventName}
)
Note that if you're expecting a broadcast to emit from the server as a response to your emission, make sure you create the listener first before emitting an event from your tester.