package com.tashow.cloud.infra.api.websocket;


import com.tashow.cloud.common.pojo.CommonResult;
import com.tashow.cloud.infraapi.api.websocket.WebSocketSenderApi;
import com.tashow.cloud.infraapi.api.websocket.dto.WebSocketSendReqDTO;
import com.tashow.cloud.websocket.core.sender.WebSocketMessageSender;
import jakarta.annotation.Resource;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RestController;

import static com.tashow.cloud.common.pojo.CommonResult.success;

@RestController // 提供 RESTful API 接口，给 Feign 调用
@Validated
public class WebSocketSenderApiImpl implements WebSocketSenderApi {
//
    @Resource
    private WebSocketMessageSender webSocketMessageSender;

    @Override
    public CommonResult<Boolean> send(WebSocketSendReqDTO message) {
//        if (StrUtil.isNotEmpty(message.getSessionId())) {
//            webSocketMessageSender.send(message.getSessionId(),
//                    message.getMessageType(), message.getMessageContent());
//        } else if (message.getUserType() != null && message.getUserId() != null) {
//            webSocketMessageSender.send(message.getUserType(), message.getUserId(),
//                    message.getMessageType(), message.getMessageContent());
//        } else if (message.getUserType() != null) {
//            webSocketMessageSender.send(message.getUserType(),
//                    message.getMessageType(), message.getMessageContent());
//        }
        return success(true);
    }

}
