不知道喵
This commit is contained in:
@@ -3,41 +3,33 @@ import http from 'node:http'
|
||||
import express from 'express'
|
||||
import { Server as SocketIoServer } from 'socket.io'
|
||||
|
||||
// 类型提示
|
||||
import { TheWhiteSilkParams, CallbackMessage } from './Types.js'
|
||||
|
||||
const app = express()
|
||||
const httpApp = http.createServer(app)
|
||||
const io = new SocketIoServer(httpApp, {})
|
||||
|
||||
class ThewhiteSilkParams {
|
||||
/**
|
||||
* @type { String }
|
||||
*/
|
||||
method
|
||||
/**
|
||||
* @type { Object }
|
||||
*/
|
||||
args
|
||||
}
|
||||
|
||||
const events = []
|
||||
const events = {}
|
||||
import { UserApi } from './api/User.js'
|
||||
|
||||
for (let i of [
|
||||
UserApi
|
||||
UserApi,
|
||||
]) {
|
||||
for (let i2 of Object.keys(i)) {
|
||||
events.push(i[i2])
|
||||
events[i2] = i[i2]
|
||||
}
|
||||
}
|
||||
|
||||
io.on("connection", (socket) => {
|
||||
socket.on('the_white_silk',
|
||||
/**
|
||||
* @param { ThewhiteSilkParams } params
|
||||
* @param { Function } callback
|
||||
* @param { TheWhiteSilkParams } params
|
||||
* @param { Function<> } callback
|
||||
*/
|
||||
(params, callback) => {
|
||||
if ((params || callback) == null) return;
|
||||
|
||||
if ((params || callback) == null || typeof callback != Function) return;
|
||||
(events[params.method] || (() => callback({mess})))(params.args)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user