1
0
forked from noxious/server

#169 : Re-enabled command manager, created extrudeTiles command for testing

This commit is contained in:
2024-09-30 19:02:55 +02:00
parent ddeee356b4
commit 3a83f2c1ff
5 changed files with 169 additions and 32 deletions

View File

@ -1,19 +1,19 @@
import fs from 'fs'
import path from 'path'
import express, { Application } from 'express'
import config from './utilities/config'
import { createServer as httpServer, Server as HTTPServer } from 'http'
import { addHttpRoutes } from './utilities/http'
import cors from 'cors'
import { Server as SocketServer } from 'socket.io'
import { TSocket } from './utilities/types'
import config from './utilities/config'
import prisma from './utilities/prisma'
import ZoneManager from './managers/zoneManager'
import UserManager from './managers/userManager'
import { Authentication } from './middleware/authentication'
// import CommandManager from './managers/CommandManager'
import { TSocket } from './utilities/types'
import prisma from './utilities/prisma'
import { Dirent } from 'node:fs'
import { appLogger, watchLogs } from './utilities/logger'
import ZoneManager from './managers/zoneManager'
import UserManager from './managers/userManager'
import CommandManager from './managers/commandManager'
import CharacterManager from './managers/characterManager'
import QueueManager from './managers/queueManager'
@ -58,12 +58,12 @@ export class Server {
appLogger.error(`Socket.IO failed to start: ${error.message}`)
}
// Load queue manager
await QueueManager.boot(this.io)
// Add http API routes
await addHttpRoutes(this.app)
// Load queue manager
await QueueManager.boot(this.io)
// Load user manager
await UserManager.boot()
@ -73,8 +73,8 @@ export class Server {
// Load character manager
await CharacterManager.boot()
// Load command manager - Disabled for now
// await CommandManager.boot(this.io);
// Load command manager
await CommandManager.boot(this.io);
// Listen for socket connections
this.io.on('connection', this.handleConnection.bind(this))
@ -106,15 +106,9 @@ export class Server {
try {
const module = await import(fullPath)
if (typeof module.default === 'function') {
if (module.default.prototype && module.default.prototype.listen) {
// This is a class-based event
const EventClass = module.default
const eventInstance = new EventClass(this.io, socket)
eventInstance.listen()
} else {
// This is a function-based event
module.default(this.io, socket)
}
const EventClass = module.default
const eventInstance = new EventClass(this.io, socket)
eventInstance.listen()
} else {
appLogger.warn(`Unrecognized export in ${file.name}`)
}