entryHandler.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. module.exports = function(app) {
  2. return new Handler(app);
  3. };
  4. var Handler = function(app) {
  5. this.app = app;
  6. };
  7. /**
  8. * New client entry.
  9. *
  10. * @param {Object} msg request message
  11. * @param {Object} session current session object
  12. * @param {Function} next next step callback
  13. * @return {Void}
  14. */
  15. Handler.prototype.entry = function(msg, session, next) {
  16. next(null, {code: 200, msg: 'game server is ok.'});
  17. };
  18. /**
  19. * Publish route for mqtt connector.
  20. *
  21. * @param {Object} msg request message
  22. * @param {Object} session current session object
  23. * @param {Function} next next step callback
  24. * @return {Void}
  25. */
  26. Handler.prototype.publish = function(msg, session, next) {
  27. var result = {
  28. topic: 'publish',
  29. payload: JSON.stringify({code: 200, msg: 'publish message is ok.'})
  30. };
  31. next(null, result);
  32. };
  33. /**
  34. * Subscribe route for mqtt connector.
  35. *
  36. * @param {Object} msg request message
  37. * @param {Object} session current session object
  38. * @param {Function} next next step callback
  39. * @return {Void}
  40. */
  41. Handler.prototype.subscribe = function(msg, session, next) {
  42. var result = {
  43. topic: 'subscribe',
  44. payload: JSON.stringify({code: 200, msg: 'subscribe message is ok.'})
  45. };
  46. next(null, result);
  47. };