
com.huaweicloud.sdk.iot.device.transport.Connection Maven / Gradle / Ivy
/*
* Copyright (c) 2020-2023 Huawei Cloud Computing Technology Co., Ltd. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* 3. Neither the name of the copyright holder nor the names of its contributors may be used
* to endorse or promote products derived from this software without specific prior written
* permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.huaweicloud.sdk.iot.device.transport;
import com.huaweicloud.sdk.iot.device.client.CustomOptions;
/**
* IOT连接,代表设备和平台之间的一个连接
*/
public interface Connection {
/**
* 建立连接
*
* @return 连接建立结果,0表示成功,其他表示失败
*/
int connect();
/**
* 发布消息
*
* @param message 消息
* @param listener 发布监听器
*/
void publishMessage(RawMessage message, ActionListener listener);
/**
* 关闭连接
*/
void close();
/**
* 是否连接中
*
* @return true表示在连接中,false表示断连
*/
boolean isConnected();
/**
* 设置链路监听器
*
* @param connectListener 链路监听器
*/
void setConnectListener(ConnectListener connectListener);
/**
* @param topic 订阅自定义topic。注意SDK会自动订阅平台定义的topic
* @param actionListener 监听订阅是否成功
* @param qos qos
*/
void subscribeTopic(String topic, ActionListener actionListener, int qos);
/**
* 设置连接动作监听器
*
* @param connectActionListener 连接动作监听器
*/
void setConnectActionListener(ConnectActionListener connectActionListener);
/**
* 设置自定义参数选项
* @param customOptions 自定义参数选项
*/
void setCustomOptions(CustomOptions customOptions);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy