public class MobileChannel extends java.lang.Object implements IMobileChannel
| Constructor and Description |
|---|
MobileChannel() |
| Modifier and Type | Method and Description |
|---|---|
void |
asyncSendRequest(java.lang.String topic,
java.util.Map<java.lang.String,java.lang.Object> opts,
java.lang.Object params,
IMobileRequestListener listener)
RPC请求接口,封装了业务的上行request以及下行resp。
|
void |
ayncSendPublishRequest(java.lang.String topic,
java.lang.Object params,
IMobileRequestListener listener)
发布消息接口,不同于[invokeWithMethod:opts:params:respHandler:]。这个接口不会有业务回执。
|
void |
bindAccount(java.lang.String iotToken,
IMobileRequestListener listener)
账号绑定长连通道
|
void |
endConnect()
长连接通道关闭异步接口
|
void |
endConnect(long waitTime,
IMqttActionListener listener)
长连接通道关闭异步接口
|
java.lang.String |
getClientId()
建联成功后,可获取ClientID
|
static IMobileChannel |
getInstance() |
MobileConnectState |
getMobileConnectState()
获取当前长连接通道状态
|
void |
registerConnectListener(boolean uiSafey,
IMobileConnectListener listener)
注册通道的状态变化
|
void |
registerDownstreamListener(boolean uiSafey,
IMobileDownstreamListener listener)
设置通道的下推回调,如果不需要用的时候,记得调用removeDownStreamListener
|
static void |
setOpenLog(boolean logFlag) |
void |
startConnect(Context context,
MobileConnectConfig config,
IMobileConnectListener listener)
长连接通道启动接口,应用起来时调用一次
|
void |
subscrbie(java.lang.String topic,
IMobileSubscrbieListener listener)
app订阅topic的接口
|
void |
unBindAccount(IMobileRequestListener listener)
长连通道解除绑定当前账号
|
void |
unRegisterConnectListener(IMobileConnectListener listener)
取消注册通道的状态变化监听
|
void |
unRegisterDownstreamListener(IMobileDownstreamListener listener)
取消某个通道的下推回调
|
void |
unSubscrbie(java.lang.String topic,
IMobileSubscrbieListener listener)
app取消订阅topic的接口
|
public static IMobileChannel getInstance()
public static void setOpenLog(boolean logFlag)
public void startConnect(Context context,
MobileConnectConfig config,
IMobileConnectListener listener)
IMobileChannelstartConnect in interface IMobileChannelconfig - app身份鉴权配置项listener - 反馈通道状态变化public void endConnect()
IMobileChannelendConnect in interface IMobileChannelpublic void endConnect(long waitTime,
IMqttActionListener listener)
IMobileChannelendConnect in interface IMobileChannelpublic MobileConnectState getMobileConnectState()
IMobileChannelgetMobileConnectState in interface IMobileChannelpublic java.lang.String getClientId()
IMobileChannelgetClientId in interface IMobileChannelpublic void bindAccount(java.lang.String iotToken,
IMobileRequestListener listener)
IMobileChannelbindAccount in interface IMobileChanneliotToken - 帐号登录后去IoT后台申请的tokenlistener - 绑定结束的Listenerpublic void unBindAccount(IMobileRequestListener listener)
IMobileChannelunBindAccount in interface IMobileChannellistener - 绑定结束的Listenerpublic void asyncSendRequest(java.lang.String topic,
java.util.Map<java.lang.String,java.lang.Object> opts,
java.lang.Object params,
IMobileRequestListener listener)
IMobileChannelasyncSendRequest in interface IMobileChanneltopic - rpc请求的topic,由具体业务确定,上行的完整topic形如:
/sys/${productKey}/${deviceName}/app/up/abc/cba
其中App 端 Topic 订阅协议前缀:/sys/${productKey}/${deviceName}/app/up 在sdk中会自动补齐。
所以开发者只需要传完整topic的业务部分,如上例中的/abc/cba即可。
也可以使用通配符 如/abc/#.opts - 可选配置项,可空,预留params - 业务参数。listener - 业务服务器响应回调接口public void ayncSendPublishRequest(java.lang.String topic,
java.lang.Object params,
IMobileRequestListener listener)
IMobileChannelayncSendPublishRequest in interface IMobileChanneltopic - rpc请求的topic,由具体业务确定,上行的完整topic形如:
/sys/${productKey}/${deviceName}/app/up/abc/cba
其中App 端 Topic 订阅协议前缀:/sys/${productKey}/${deviceName}/app/up 在sdk中会自动补齐。
所以开发者只需要传完整topic的业务部分,如上例中的/abc/cba即可。
也可以使用通配符 如/abc/#.public void subscrbie(java.lang.String topic,
IMobileSubscrbieListener listener)
IMobileChannelsubscrbie in interface IMobileChanneltopic - 订阅的消息的topic,由具体业务确定,只需要传业务方的区段,公用区段不需要传.
可以参见asyncSendRequest 中的topic定义listener - 订阅流程结束的监听public void unSubscrbie(java.lang.String topic,
IMobileSubscrbieListener listener)
IMobileChannelunSubscrbie in interface IMobileChanneltopic - 订阅的消息的topic,由具体业务确定,只需要传业务方的区段,公用区段不需要传.
可以参见invokeWithTopic:opts:params:respHandler: 中的topic定义listener - 订阅流程结束的监听public void registerDownstreamListener(boolean uiSafey,
IMobileDownstreamListener listener)
IMobileChannelregisterDownstreamListener in interface IMobileChanneluiSafey - 是否要在UI线程里回调,建议为YESpublic void unRegisterDownstreamListener(IMobileDownstreamListener listener)
IMobileChannelunRegisterDownstreamListener in interface IMobileChannelpublic void registerConnectListener(boolean uiSafey,
IMobileConnectListener listener)
IMobileChannelregisterConnectListener in interface IMobileChanneluiSafey - 是否需要在UI线程回调public void unRegisterConnectListener(IMobileConnectListener listener)
IMobileChannelunRegisterConnectListener in interface IMobileChannel