Closed caracal7 closed 4 years ago
I think that might be because your not implementing the actual plugin interface.
Will look at it and get back to you
const DeepstreamServer = new Deepstream( {
httpServer: {
type: 'default',
options: {
port: 6020,
host: '127.0.0.1'
}
},
auth: [{
path: './PATH/my-authentication.js',
options: {}
}]
})
my-authentication.js
const { DeepstreamPlugin } = require('@deepstream/types')
module.exports = class TokenAuthentication extends DeepstreamPlugin {
constructor ( pluginOptions, services) {
super()
}
async isValidUser(connectionData, authData) {
console.log('isValidUser')
return null
}
async whenReady () {
console.log('whenReady')
}
// This event never fired!!!
async onClientDisconnect( username ) {
console.log( 'onClientDisconnect', username )
}
}
also didn't work
@yasserf No ideas how to catch onClientDisconnect event?
I didn't know TypeScript. I make little hack and solve my problem
deepstream.io/src/connection-endpoint/base/connection-endpoint.ts line:385
if (this.services.authentication.onClientDisconnect) {
this.services.authentication.onClientDisconnect(socketWrapper.user)
I changed to
// @ts-ignore
if (this.services.authentication.auths[0].onClientDisconnect) {
// @ts-ignore
this.services.authentication.auths[0].onClientDisconnect(socketWrapper.userId)
But this is not good solution 🤗
Hey!
That’s almost completely correct, just needs to be a loop instead. I’ll put in the fix. Thank you finding it!
On Sat, 8 Feb 2020 at 09:44, Dmitry notifications@github.com wrote:
I didn't know TypeScript. I make little hack witch solve my problem
deepstream.io/src/connection-endpoint/base/connection-endpoint.ts line:385
if (this.services.authentication.onClientDisconnect) {
this.services.authentication.onClientDisconnect(socketWrapper.user)
I changed to
// @ts-ignore
if (this.services.authentication.auths[0].onClientDisconnect) {
// @ts-ignore
this.services.authentication.auths[0].onClientDisconnect(socketWrapper.userId)
But this is not good solution 🤗
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/deepstreamIO/deepstream.io/issues/1038?email_source=notifications&email_token=AAU3WS242L5LWL2IGORXNL3RBXB3LA5CNFSM4KIOOPKKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOELERB5I#issuecomment-583602421, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAU3WSYZWVTNUXG5AG7HXT3RBXB3LANCNFSM4KIOOPKA .
Should be fixed in 5.0.6, let me know!
@yasserf Version 5.0.7
deepstream.io/src/connection-endpoint/base/connection-endpoint.ts line:386
this.services.authentication.onClientDisconnect(socketWrapper.user)
need to be replaced to
this.services.authentication.onClientDisconnect(socketWrapper.userId)
in order to onClientDisconnect return ID
Interesting that didn’t get caught by typescript. Will look at it.
@yasserf did you fix with issue?
I put in a fix but DS didnt release due an NPM issue which I didn’t look into
Thanks a lot )
Released in 5.0.9
Server code