hallRemote.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. 'use strict';
  2. var P = require('quick-pomelo').Promise;
  3. var util = require('util');
  4. var logger = require('quick-pomelo').logger.getLogger('hallRemote', __filename);
  5. var Remote = function (app) {
  6. this.app = app;
  7. };
  8. module.exports = function (app) {
  9. return new Remote(app);
  10. };
  11. Remote.prototype.leave = function (playerId, cb) {
  12. var app = this.app;
  13. return app.memdb.goose.transactionAsync(function () {
  14. // console.warn("大厅用户离开了");
  15. app.controllers.bisai.delPlayer(playerId);
  16. return ;
  17. }, app.getServerId())
  18. .then(res => (app.event.emit('transactionSuccess'), res), res => (app.event.emit('transactionFail'), res))
  19. .nodeify(cb);
  20. };
  21. Remote.prototype.creatTable = function (data, cb) {
  22. var app = this.app;
  23. return app.memdb.goose.transactionAsync(function () {
  24. // console.warn("hallremote 大厅创建房间 "+JSON.stringify(data));
  25. app.controllers.bisai.addTable(data.id,data.agentId,data.playerAllCount);
  26. return ;
  27. }, app.getServerId())
  28. .then(res => (app.event.emit('transactionSuccess'), res), res => (app.event.emit('transactionFail'), res))
  29. .nodeify(cb);
  30. };
  31. Remote.prototype.delTable = function (data, cb) {
  32. var app = this.app;
  33. return app.memdb.goose.transactionAsync(function () {
  34. // console.warn("大厅删除房间 ");
  35. app.controllers.bisai.delTable(data.id,data.agentId);
  36. return ;
  37. }, app.getServerId())
  38. .then(res => (app.event.emit('transactionSuccess'), res), res => (app.event.emit('transactionFail'), res))
  39. .nodeify(cb);
  40. };