public class GatewayChannel extends java.lang.Object implements IGatewayChannel
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DID_SEPARATOR |
Modifier and Type | Method and Description |
---|---|
void |
addSubDevice(SubDeviceInfo deviceInfo,
ISubDeviceConnectListener subDeviceConnectListener)
建立 topo 关系
|
void |
asyncSendRequest(java.lang.String topic,
java.lang.String method,
java.util.Map<java.lang.String,java.lang.Object> opts,
java.lang.Object params,
IGatewayRequestListener listener)
RPC请求接口,封装了业务的上行request以及下行resp。
|
void |
ayncSendPublishRequest(java.lang.String topic,
java.lang.String method,
java.util.Map<java.lang.String,java.lang.Object> opts,
java.lang.Object params,
IGatewayRequestListener listener)
发布消息接口,不同于asyncSendRequest。这个接口不会有业务回执。
|
void |
destroyConnect()
断开长链接通道
|
void |
deviceListUpload(java.util.List<SubDeviceInfo> foundList,
IConnectSendListener listener)
上报发现的子设备列表
可能用于第三方应用获取并选择添加拓扑关系
|
GatewayConnectState |
getGatewayConnectState()
获取当前长连接通道状态
|
static IGatewayChannel |
getInstance() |
ISubDeviceChannel |
getSubDeviceChannel(java.lang.String sudDeviceId)
获取子设备连接通道
|
void |
getSubDevices(IConnectSendListener listener)
获取子设备列表
|
void |
registerDownstreamListener(boolean uiSafey,
IGatewayDownstreamListener listener)
设置通道的下推回调,如果不需要用的时候,unRegisterDownstreamListener
|
void |
removeSubDevice(SubDeviceInfo subDeviceInfo,
ISubDeviceRemoveListener removeListener)
删除 topo 关系
|
void |
startConnect(Context context,
GatewayConnectConfig config,
IGatewayConnectListener listener)
长连接通道启动接口,应用起来时调用一次
|
void |
startConnectReuseMobileChannel(Context context,
IGatewayConnectListener listener)
长连接通道启动借口给,复用Mobile Channel接口
|
void |
subDeviceRegister(java.util.List<SubDeviceInfo> infoList,
IConnectSendListener listener)
子设备动态注册
|
void |
subDevicUnregister(java.util.List<SubDeviceInfo> infoList,
IConnectSendListener listener)
取消子设备动态注册
|
void |
subscribe(java.lang.String topic,
IGatewaySubscribeListener listener)
app订阅topic的接口
|
void |
unRegisterDownstreamListener(IGatewayDownstreamListener listener)
取消某个通道的下推回调
|
void |
unSubscribe(java.lang.String topic,
IGatewaySubscribeListener listener)
app取消订阅topic的接口
|
public static final java.lang.String DID_SEPARATOR
public static IGatewayChannel getInstance()
public void startConnect(Context context, GatewayConnectConfig config, IGatewayConnectListener listener)
IGatewayChannel
startConnect
in interface IGatewayChannel
config
- 通道建联配置项listener
- 反馈通道状态变化public void startConnectReuseMobileChannel(Context context, IGatewayConnectListener listener)
IGatewayChannel
startConnectReuseMobileChannel
in interface IGatewayChannel
listener
- 反馈通道状态变化public GatewayConnectState getGatewayConnectState()
IGatewayChannel
getGatewayConnectState
in interface IGatewayChannel
public void subDeviceRegister(java.util.List<SubDeviceInfo> infoList, IConnectSendListener listener)
IGatewayChannel
subDeviceRegister
in interface IGatewayChannel
infoList
- 子设备列表listener
- 监听器public void subDevicUnregister(java.util.List<SubDeviceInfo> infoList, IConnectSendListener listener)
IGatewayChannel
subDevicUnregister
in interface IGatewayChannel
infoList
- 子设备列表listener
- 监听器public void addSubDevice(SubDeviceInfo deviceInfo, ISubDeviceConnectListener subDeviceConnectListener)
IGatewayChannel
addSubDevice
in interface IGatewayChannel
deviceInfo
- 子设备信息subDeviceConnectListener
- 子设备上下行数据通道public void removeSubDevice(SubDeviceInfo subDeviceInfo, ISubDeviceRemoveListener removeListener)
IGatewayChannel
removeSubDevice
in interface IGatewayChannel
subDeviceInfo
- 子设备信息public void getSubDevices(IConnectSendListener listener)
IGatewayChannel
getSubDevices
in interface IGatewayChannel
listener
- 监听器public void deviceListUpload(java.util.List<SubDeviceInfo> foundList, IConnectSendListener listener)
IGatewayChannel
deviceListUpload
in interface IGatewayChannel
foundList
- 子设备列表listener
- 监听器public void asyncSendRequest(java.lang.String topic, java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> opts, java.lang.Object params, IGatewayRequestListener listener)
IGatewayChannel
asyncSendRequest
in interface IGatewayChannel
topic
- topic rpc请求的topic,由具体业务确定,完整topic形如:
/sys/${productKey}/${deviceName}/app/abc/cba
其中App 端 Topic 订阅协议前缀:/sys/${productKey}/${deviceName}/app/
所以开发者只需要传完整topic的业务部分,如上例中的abc/cba即可。
也可以使用通配符 如abc/#.method
- payload 中的methodopts
- 可选配置项,可空,预留params
- 业务参数。listener
- 业务服务器响应回调接口public void ayncSendPublishRequest(java.lang.String topic, java.lang.String method, java.util.Map<java.lang.String,java.lang.Object> opts, java.lang.Object params, IGatewayRequestListener listener)
IGatewayChannel
ayncSendPublishRequest
in interface IGatewayChannel
topic
- rpc请求的topic,由具体业务确定,上行的完整topic形如:
/sys/${productKey}/${deviceName}/app/up/abc/cba
其中App 端 Topic 订阅协议前缀:/sys/${productKey}/${deviceName}/app/up 在sdk中会自动补齐。
所以开发者只需要传完整topic的业务部分,如上例中的/abc/cba即可。
也可以使用通配符 如/abc/#.public void subscribe(java.lang.String topic, IGatewaySubscribeListener listener)
IGatewayChannel
subscribe
in interface IGatewayChannel
topic
- 订阅的消息的topic,由具体业务确定,只需要传业务方的区段,公用区段不需要传.
可以参见invokeWithTopic:opts:params:respHandler: 中的topic定义listener
- 订阅流程结束的监听public void unSubscribe(java.lang.String topic, IGatewaySubscribeListener listener)
IGatewayChannel
unSubscribe
in interface IGatewayChannel
topic
- 订阅的消息的topic,由具体业务确定,只需要传业务方的区段,公用区段不需要传.
可以参见asyncSendRequest 中的topic定义listener
- 订阅流程结束的监听public void registerDownstreamListener(boolean uiSafey, IGatewayDownstreamListener listener)
IGatewayChannel
registerDownstreamListener
in interface IGatewayChannel
uiSafey
- 是否要在UI线程里回调,建议为YESpublic void unRegisterDownstreamListener(IGatewayDownstreamListener listener)
IGatewayChannel
unRegisterDownstreamListener
in interface IGatewayChannel
public ISubDeviceChannel getSubDeviceChannel(java.lang.String sudDeviceId)
IGatewayChannel
getSubDeviceChannel
in interface IGatewayChannel
sudDeviceId
- 子设备ID pk+dnpublic void destroyConnect()
IGatewayChannel
destroyConnect
in interface IGatewayChannel