package com.rehome.sgbaxj.service;


import android.app.Service;
import android.content.Intent;
import android.os.Binder;
import android.os.IBinder;
import android.os.Looper;

import androidx.annotation.Nullable;
import com.rehome.sgbaxj.utils.MqttSSLPublishServer;

import org.eclipse.paho.android.service.MqttAndroidClient;
import org.eclipse.paho.client.mqttv3.MqttConnectOptions;

public class MQTTPushService extends Service {
    private int one;
    private SimpleBinder mBinder;
    public MqttAndroidClient mClient;
    private MqttConnectOptions options;
    public static String clientId = "android";

    @Override
    public void onCreate() {
        super.onCreate();
        mBinder = new SimpleBinder();
        MqttSSLPublishServer mqttPublishServer = new MqttSSLPublishServer(this);
        mqttPublishServer.start();
    }

    @Nullable
    @Override
    public IBinder onBind(Intent intent) {
        if (mBinder != null) {
            return mBinder;
        }
        return null;
    }
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        return super.onStartCommand(intent, flags, startId);
    }

    @Override
    public void onDestroy() {
        super.onDestroy();
    }

    class SimpleBinder extends Binder {

        public void doTask() {
            new Thread(new Runnable() {
                @Override
                public void run() {
                    // 任务逻辑
                }
            }).start();
        }
    }

    public boolean isMainThread() {
        return Looper.getMainLooper().getThread() == Thread.currentThread();
    }
}
