could you expose internal APIs of WebSocket such as WebsocketFrameSend to user?
What is the problem this feature will solve?
expose more APIs of websocket module:
const value = Buffer.from(data);
const frame = new WebsocketFrameSend(value);
const buffer = frame.createFrame(opcodes.BINARY);
What is the feature you are proposing to solve the problem?
expose more APIs of websocket module:
const value = Buffer.from(data);
const frame = new WebsocketFrameSend(value);
const buffer = frame.createFrame(opcodes.BINARY);
What alternatives have you considered?
No response
Can you explain your use case in more detail?
As @fahrradflucht said, for a feature to be added to Node.js, there needs to be a use case, do you have one?
Thank you!
in one of my project: the equipment(work as websocket client, most of them using nodejs) need to send msg(short but frequentlty) to some upstream-servers . unfortunately, the upstream-servers NOT under our control. and some of them NOT obey the standard-websocket-protocol(they do a private implement), so need the client to send some specical low-level ws-frame to them.
@navegador5 see https://github.com/websockets/ws/blob/ddfe4a804d79e7788ab136290e609f91cf68423f/lib/sender.js#L49-L70. It is not documented due to permessage-deflate constraints.
You can use it like this
const { Sender } = require('ws'); // or import { Sender } from 'ws';
const data = Buffer.alloc(256);
const buffers = Sender.frame(data, { opcode: 2 });
const frame = Buffer.concat(buffers);