package com.ruoyi.cai.ws.handler.message;

import com.alibaba.fastjson2.JSONObject;
import com.ruoyi.cai.ws.bean.FdCtxData;
import com.ruoyi.cai.ws.bean.Room;
import com.ruoyi.cai.ws.handler.IMessageHandler;
import com.ruoyi.cai.ws.service.RoomService;
import com.ruoyi.cai.ws.dto.WsRMsgGen;
import com.ruoyi.cai.ws.handler.AbstractMessageHandle;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * 获取可通话时长
 */
@Component("cancalltime")
public class CanCallTimeMessageHandler extends AbstractMessageHandle implements IMessageHandler {
    @Autowired
    private RoomService roomService;
    @Override
    public void processOn(Room room, FdCtxData fdCtxData, JSONObject map) {
        Long time = roomService.canCallTime(room);
        sendToCurrent(fdCtxData,WsRMsgGen.canCallTime(time));
    }
}
