Add default callback function (#436)

This commit is contained in:
碎碎酱 2021-08-24 13:23:06 +08:00 committed by GitHub
parent fa233d4633
commit ea76e10f06
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -3,8 +3,12 @@ import logger from '@fiora/utils/logger';
import { getSocketIp } from '@fiora/utils/socket';
import { Socket } from 'socket.io';
function defaultCallback() {
logger.error('Server Error: emit event with callback');
}
export default function registerRoutes(socket: Socket, routes: Routes) {
return async ([event, data, cb]: MiddlewareArgs) => {
return async ([event, data, cb = defaultCallback]: MiddlewareArgs) => {
const route = routes[event];
if (route) {
try {