AOP Socket.io Java

26 views Asked by At

`I use AOP for API controllers, services, or any classes, and it works for all of them. However, with socket.io, it doesn't work

@Aspect
@Component
@Slf4j
public class ExecutionTimeLoggerAspect {
    @Around("execution(* com.socket.handler.*.*(..))")
    public Object logExecutionTime(ProceedingJoinPoint joinPoint) throws Throwable {
        long startTime = System.currentTimeMillis();
        Object result = joinPoint.proceed();
        long endTime = System.currentTimeMillis();
        long executionTime = endTime - startTime;
        log.info("Method " + joinPoint.getSignature() + " executed in " + executionTime + " ms");
        return result;
    }
}

package com.socket.handler; 
...
 @OnEvent(SocketEventEnums.TypeActionEvent.TURN_ON_PRESENTATION)
    public void turnOnPresentation(SocketIOClient client, BoothDto data) throws Exception {
        log.info("Client[{} - {}] - Listen event {} - Data: {}", client.getSessionId(), client.get("userId"),
                SocketEventEnums.TypeActionEvent.TURN_ON_PRESENTATION, data);
        boothService.onBoothEvent(client, data, SocketEventEnums.TypeMessageSend.PRESENTATION_ON);
    }

Explain or provide a solution for me, please.`

0

There are 0 answers