Closed TangMonk closed 7 years ago
here is authenticate method:
const authenticate = function (client, username, password, callback) { debug(`login with username: ${username}, password: ${password}`) console.log(username, password); if (!username || !password) { return callback(null, false); } Car.findOne({ where: { car_login_name: username, car_password: md5(password) } }).then((car) => { if (!car) { callback(null, false); } else { client.user = car; callback(null, true); } }) } server.authenticate = authenticate
here is published and clientConnected method:
server.on('published', function (packet, client) { debug(`published: username: ${client.user}, topic: ${packet.topic}`) }); server.on('clientConnected', function (client) { debug(`connected: username: ${client.use}`) });
The user will log to console in clientConnected, but cannot lot in published
clientConnected
published
there are internal messages published by the broker (stats, etc) for which there is no client.
here is authenticate method:
here is published and clientConnected method:
The user will log to console in
clientConnected
, but cannot lot inpublished