package me.koba1.led.simulator;

import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

import java.util.Map;

@Service
public class SimulatorService {

    private final WebClient webClient;

    public SimulatorService(WebClient webClient) {
        this.webClient = webClient;
    }

    public void sendColors(Map<Integer, Integer> colors) {
        webClient.post()
                .uri("http://192.168.1.23:8001/colors")
                .bodyValue(colors)
                .retrieve()
                .bodyToMono(String.class)
                .onErrorResume(e -> Mono.empty())
                .subscribe();
    }
}
