mirror of
https://github.com/yinxin630/fiora.git
synced 2026-06-04 21:03:18 +08:00
Add default callback function (#436)
This commit is contained in:
parent
fa233d4633
commit
ea76e10f06
@ -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 {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user