Home › Forums › kdb+ › Async broadcast to websocket handles using internal function -25! › Re: Async broadcast to websocket handles using internal function -25!
-
-25! is for use with IPC handles only. Not websocket handles.
The reason is for IPC handles there is a serialization step and here -25! is efficient in allowing this to only be run once for many handles.
For websocket handles data is sent directly without any serialization step, -25! would offer no benefit here.
- https://code.kx.com/q/basics/internal/#-25x-async-broadcast
- https://code.kx.com/q/basics/internal/#-38x-socket-table
q){([]h)!-38!h:.z.H}[] h | p f ---| --- 612| w t 580| q t q)-25!(enlist 612i;"test") '612 is not an ipc handle [0] -25!(enlist 612i;"test") ^ q)-25!(enlist 580i;"test")
For websockets if there is a large operation like converting a table to JSON you can control this being done once and then sent to multiple websockets:
neg[webSockethandles]@:.j.j bigTable
Wrapping the same in a helper:
wsBroadcast:{[handles;data] neg[(),handles]@:data} wsBroadcast[myWebsocketHandles] .j.j bigTable