package com.caliverse.admin.domain.api;

import com.caliverse.admin.domain.RabbitMq.message.LogoutReasonType;
import com.caliverse.admin.domain.RabbitMq.RabbitMqService;

import com.caliverse.admin.domain.RabbitMq.message.ServerMessage;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

@Tag(name = "Test", description = "RabbitMQ TestApi")
@RestController
@RequestMapping("/api/v1/RabbitMQTest")
public class TestController {

    private RabbitMqService m_rabbitMq;

    public TestController(RabbitMqService rabbitMq) {
        this.m_rabbitMq = rabbitMq;
    }


    // Send Test
    @PostMapping("/send")
    public void sendRabbitMq() throws IOException, TimeoutException {

        var user_kick_builder = ServerMessage.MOS2GS_NTF_USER_KICK.newBuilder();
        user_kick_builder.setUserGuid("09022548-53c8-44a0-ad5d-5df98ef7b61a");
        user_kick_builder.setKickReasonMsg("reason");
        user_kick_builder.setLogoutReasonType(LogoutReasonType.LogoutReasonType_None);

        m_rabbitMq.SendMessage(user_kick_builder.build(), "Channel:001:001");
    }
}
