-
Notifications
You must be signed in to change notification settings - Fork 64
Open
Description
Currently, if you start a server, it will always receive data via onread() because of JSSocket.h#L79.
This is a bit confusing, is this a wanted API? It will eventually lead to users having to create a cache for both their wrappers and the nidium sockets, just to answer to the corresponding socket correctly.
Example 1 (current behaviour)
let server = new Socket('127.0.0.1', 1234).listen('tcp');
server.onaccept = socket => console.log(socket.ip, socket.port);
server.onread = (socket, data) => console.log('server.onread always fired', data);Example 2 (expected behaviour)
let server = new Socket('127.0.0.1', 1234).listen('tcp');
server.onaccept = function(socket) {
socket.onread = function(data) {
// XXX: Never actually fired
console.log('this is a much better API, per-client onread', data);
};
};
server.onread = (socket, data) => console.log('server.onread always fired', data);Metadata
Metadata
Assignees
Labels
No labels