All Downloads are FREE. Search and download functionalities are using the official Maven repository.

test.Main Maven / Gradle / Ivy

The newest version!
package test;

import com.labstack.Client;
import com.labstack.Mqtt;
import com.labstack.MqttMessageHandler;

import java.text.DateFormat;
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;

public class Main {
    public static void main(String[] args) throws Exception {
//        Client.print();
//        DateFormat dateFormatter = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ");
//        System.out.println(dateFormatter.format(new Date()));
        Client client = new Client("ie8t5fgcb6s2vaxgg02y", "VouXFKK2A1TkuMUVz3wV2zvmapIdRuFM");
        Mqtt mqtt = client.Mqtt("eYopW5UJeoc");
        mqtt.onMessage(new MqttMessageHandler() {
            @Override
            public void handle(String topic, byte[] payload) {
                System.out.println(topic);
                System.out.println(new String(payload));
            }
        });
        mqtt.subscribe("tracker");
//        Email email = client.Email();
//        EmailMessage message = new EmailMessage("[email protected]", "LabStack", "Hello");
//        message.setBody("Hello");
//        message.addAttachment("/tmp/walle.png");
//        message = email.send(message);
//        Store store = client.Store();
//        Document document = store.insert("users", new Document()
//                .add("name", "Jack")
//                .add("location", "Disney"));
//        StoreSearchResponse response = store.search("users", new SearchParameters()
//                .setQueryString("location:Disney"));
//        System.out.println(response.getTotal());
//        System.out.println(response.getTotal());
//        StoreSearchResponse response = store.query("key='user'", 0, 5);
//        System.out.println(response.getTotal());
//        Log log = client.Log();
//        log.setLevel(Level.DEBUG);
//        log.getFields().add("app_id", "id").add("app_name", "name");
//        log.setBatchSize(20);
//        log.setDispatchInterval(5);
//        log.debug(new Fields().add("message", "debug message"));
//        log.debug("debug message");
//        log.info("%s message", "info");
//        log.warn("warn message");
//        log.error("error message");
//        log.fatal("fatal message");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy