Browse Source

refactor createIoServer

develop
Rob Colbert 11 months ago
parent
commit
c873eb16e9
  1. 24
      dtp-base.js

24
dtp-base.js

@ -171,9 +171,7 @@ class SiteWebApp extends SiteRuntime {
this.app.use( this.app.use(
(req, res, next) => { (req, res, next) => {
res.locals.dtp = { res.locals.dtp = { request: req };
request: req,
};
return next(); return next();
}, },
sessionService.middleware(), sessionService.middleware(),
@ -200,15 +198,7 @@ class SiteWebApp extends SiteRuntime {
*/ */
this.httpServer = http.createServer(this.app); this.httpServer = http.createServer(this.app);
this.createIoServer();
/*
* Create Socket.io server bound to HTTP server
*/
const { SiteIoServer } = await import('./lib/site-ioserver.js');
this.log.info('creating Socket.io server');
this.io = new SiteIoServer(this);
await this.io.start(this.httpServer);
/* /*
* Start the HTTP server * Start the HTTP server
@ -230,6 +220,16 @@ class SiteWebApp extends SiteRuntime {
}); });
} }
async createIoServer ( ) {
/*
* Create Socket.io server bound to HTTP server
*/
const { SiteIoServer } = await import('./lib/site-ioserver.js');
this.log.info('creating Socket.io server');
this.io = new SiteIoServer(this);
await this.io.start(this.httpServer);
}
async loadControllers ( ) { async loadControllers ( ) {
const basePath = path.join(this.config.root, 'app', 'controllers'); const basePath = path.join(this.config.root, 'app', 'controllers');
const entries = await fs.promises.readdir(basePath, { withFileTypes: true }); const entries = await fs.promises.readdir(basePath, { withFileTypes: true });

Loading…
Cancel
Save