kick.js 349 B

1234567891011
  1. var Package = require('pomelo-protocol').Package;
  2. module.exports.handle = function(socket, reason) {
  3. // websocket close code 1000 would emit when client close the connection
  4. if(typeof reason === 'string') {
  5. var res = {
  6. reason: reason
  7. };
  8. socket.sendRaw(Package.encode(Package.TYPE_KICK, new Buffer(JSON.stringify(res))));
  9. }
  10. };