You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I do not know how complicated it would be to add this to the current implementation of mock-socket but I'm willing to try my hand at it if someone could give me better insight into where this should be done because I'm currently using the callbacks in my project to turn send into a Promise.
I've tried to dig deep into the ws implementation of send and the furthest I could get was here
Socket.prototype._writeGeneric=function(writev,data,encoding,cb){// If we are still connecting, then buffer this for later.// The Writable logic will buffer up any more writes while// waiting for this one to be done.if(this.connecting){this._pendingData=data;this._pendingEncoding=encoding;this.once('connect',functionconnect(){this._writeGeneric(writev,data,encoding,cb);});return;}this._pendingData=null;this._pendingEncoding='';if(!this._handle){cb(newERR_SOCKET_CLOSED());returnfalse;}this._unrefTimer();letreq;if(writev)req=writevGeneric(this,data,cb);elsereq=writeGeneric(this,data,encoding,cb);if(req.async)this[kLastWriteQueueSize]=req.bytes;};
After that it appears to go into C territory. I think I went a bit overboard with the digging though. I'm sure there's probably a simple implementation of the send callback to be able to mock it correctly I might be able to submit as a PR.
The text was updated successfully, but these errors were encountered:
In the original websocket implementation there is an optional callback that can be passed on to the
WebSocket.prototype.send
function.https://github.com/websockets/ws/blob/master/doc/ws.md#websocketsenddata-options-callback
I do not know how complicated it would be to add this to the current implementation of
mock-socket
but I'm willing to try my hand at it if someone could give me better insight into where this should be done because I'm currently using the callbacks in my project to turnsend
into a Promise.I've tried to dig deep into the
ws
implementation ofsend
and the furthest I could get was herews/lib/websocket.js:323
ws/lib.sender.js:252
ws/lib/sender.js:380
node/lib/net.js:778
node/lib/net.js:741
node/lib/internal/stream_base_commons.js:149
node/lib/internal/stream_base_commons.js:111
After that it appears to go into C territory. I think I went a bit overboard with the digging though. I'm sure there's probably a simple implementation of the send callback to be able to mock it correctly I might be able to submit as a PR.
The text was updated successfully, but these errors were encountered: