im-svr.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use strict';
  2. var koa = require('koa.io');
  3. var rpcWithExpress = require('./libs/rpcWithExpress');
  4. var wordFilter = require('./libs/wordfilter');
  5. var jsonp = require('koa-safe-jsonp');
  6. var router = require('koa-router');
  7. var bodyParser = require('koa-better-body');
  8. var _ = require('underscore');
  9. _.str = require('underscore.string');
  10. _.v = require('validator');
  11. var gzip = require('./libs/mygzip');//压缩页面
  12. var session = require('koa-generic-session');
  13. var redisStore = require('koa-redis');
  14. var cors = require('koa-cors');
  15. var F = require('./common/function');
  16. var C = require('./config');
  17. var apiPre = C.apiPre;
  18. var co = require('co');
  19. var modelMgr = require('./manager/model');
  20. var commonMgr = require('./manager/common');
  21. var app = new rpcWithExpress();
  22. var port = C.socketio_port;
  23. app.port = port;
  24. app.model_mgr = new modelMgr();
  25. app.common_mgr = new commonMgr(app);
  26. co(app.common_mgr.mgr_map.im.clearLock());
  27. co(app.common_mgr.mgr_map.im.clearSocket());
  28. var im_common = require('./routes/imCommon');
  29. im_common(app);
  30. // 登录相关IM接口
  31. require('./routes/imLogin')(app);
  32. // 房间消息相关IM接口
  33. require('./routes/imMsgMgr')(app);
  34. // 公聊大厅相关接口
  35. require('./routes/imPublicRoomMgr')(app);
  36. //房间队列相关IM接口
  37. require('./routes/imQueueMgr')(app);
  38. // 房间管理IM接口
  39. require('./routes/imRoomMgr')(app);
  40. app.svr.listen(port, function () {
  41. console.log('Server listening at port %d', port);
  42. });
  43. //app.setBeatTime(5000,15000);
  44. /**
  45. * @desc 监听客户端的连接和断开
  46. */