-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nice finally XD a wrapper #1
Comments
Ok, I will benchmark it. So, may will spent some time. |
I had research Socket.IO. In short-term may not implement it. Still could benchmark Socket.IO, but may not fair because they have different workflow and WS protocol. |
I had done the benchmark of Socket.IO |
don't worry I will wait as long xD it does a few socket io does. emit back and fort .. emit to specific id .. and had room feature. I will probably ditch socket io and create another new angular ngx-fastws-client emit, once, on, connect, disconnect, binary I still had to test this if this can connect faster than angular init xD like socket io and socket cluster does. reason for it. to use this inside the angular guard. /ClusterWS/cWS one failed on this test. also, do you support custom parser? like allow to use other parser to parse binary and json. for encryption purposes.. parse -> emit last setting origins to lock both express and socket to only listen to specific domain |
If only use room, emitter and binary, you can use basic protocol. app.ws('/path', (ws) => {
ws.join('Room-ID')
ws.on('binary', (binary) => {
ws.sendBinary(Buffer or String)
ws.broadcastBinary(Buffer or String)
})
}, { protocol: 'basic' }) Or you can extents the basic protocol for custom parser. const WSBasicProtocol = require('fast-ws/server/ws-protocol/basic')
class CustomProtcol extends WSBasicProtocol {
incomingPacket (packet, isBinary) {
// parse and emit
}
// I will add payload generator function at next release, that can just override it to change parser.
}
app.ws('/path', (ws) => {
}, { protocol: CustomProtcol }) |
And origins lock, this code can do it. app.ws('/path', (ws) => {
if (/^https?:\/\/your.domain/.test(ws.requestHeaders['origin'])) {
ws.close()
}
}) I will consider to add it in ws options. (last argument in |
The newest release may solve your problem. Use with basic protocol. app.ws('/path', ws => {
ws.on('message', data => {
ws.send(data)
})
}, {
protocolOptions: {
parser: {
stringify: data => something.encode(data),
parse: data => something.decode(data)
}
}
}) Or use with fast-ws protocol. (It is alternative to Socket.io) app.ws('/path', ws => {
ws.on('event', ({ data, reply }) => {
reply(data)
})
ws.on('message', data => {
ws.send(data)
})
}, {
protocolOptions: {
serialize: data => something.encode(data),
deserialize: data => something.decode(data)
}
}) |
And about origin limit. |
I see maybe soon, do you have an example of creating middleware for both ws and the express like |
can you benchmark this vs socket io, I really wanted to use this newly renamed uws xD but looking for a beautiful wrapper that I can fully understand.
The text was updated successfully, but these errors were encountered: