package com.ffii.towngas.sensor.web;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import com.ffii.core.support.AbstractController;
import com.ffii.towngas.config.MqttConsumerConfig;

@RestController
@RequestMapping("/protected/sensorData")
public class TestController extends AbstractController {

  @Value("${spring.mqtt.client.id}")
  private String clientId;

  private MqttConsumerConfig client;

  public TestController(MqttConsumerConfig client) {
    this.client = client;
  }

  @RequestMapping("connect")
  @ResponseBody
  public String connect() {
    client.connect();
    return clientId + "Connected to the server";
  }

  @RequestMapping("dis-connect")
  @ResponseBody
  public String disConnect() {
    client.disConnect();
    return clientId + "Disconnected from the server";
  }

}
