Closed renrenfree closed 7 years ago
Possible : Yes
Solution: I think it is possible in first place by using the authorisation model wisely by using the authenticate
method. So its like if the client connects and there is a DB store that stores the user's authorisation flags, which should be controlled by some other module and if the authorisation flags show non-allowance to connect for a particular user, then use the callback in following way
var authenticate = function(client, username, password, callback) {
//value of authorized is decided by your custom authorization module
if (authorized){
//for allowing to connect
callback(null, authorized);
}else{
//for disallowing to connect
callback(false,null);
}
}
server.on("ready",function(){
server.authenticate = authenticate;
});
Reference : here
You can call client.close
once you get hold of a client instance.
https://github.com/mcollina/mosca/blob/master/lib/client.js#L577
Are mosca can actively disconnect clients