createWebSocketServer
, which is a wrapper around ws
server creator. When created, it won't automatically start listening to given port and hostname until you call its awaited instance.WsEffect
which works within WebSocket protocol and deals with streams of Events. The very basic implementation of WebSocket Effect can look like in the code snipped below.Hello, world!
message. In case of default WsEffect
interface, each incoming event has to be mapped to an outgoing event which is just an object with type and payload attributes.buffer
operator, which buffers the source Observable values until closing notifier emits (in this case sum$
). Additionally, to be sure that incoming ADD events are sent with payload of type number, we used @marblejs/middleware-io validator, which is able to infer payload type from defined schema.