✨ cms增加初始化和销毁回调操作
This commit is contained in:
parent
14f2e4edda
commit
220e723d4c
|
@ -36,6 +36,9 @@ public class CmsServer {
|
||||||
private HCISUPCMS.DEVICE_REGISTER_CB deviceRegisterCb;
|
private HCISUPCMS.DEVICE_REGISTER_CB deviceRegisterCb;
|
||||||
HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM struCMSListenPara = new HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM();
|
HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM struCMSListenPara = new HCISUPCMS.NET_EHOME_CMS_LISTEN_PARAM();
|
||||||
|
|
||||||
|
private Runnable preStartCallback = null;
|
||||||
|
private Runnable stopCallback = null;
|
||||||
|
|
||||||
public CmsServer(HkSupSdkProperties supSdkProperties, ApplicationContext applicationContext) {
|
public CmsServer(HkSupSdkProperties supSdkProperties, ApplicationContext applicationContext) {
|
||||||
this.supSdkProperties = supSdkProperties;
|
this.supSdkProperties = supSdkProperties;
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
|
@ -157,6 +160,7 @@ public class CmsServer {
|
||||||
*/
|
*/
|
||||||
void startCmsServer() {
|
void startCmsServer() {
|
||||||
try {
|
try {
|
||||||
|
Optional.ofNullable(preStartCallback).ifPresent(Runnable::run);
|
||||||
cmsInit();
|
cmsInit();
|
||||||
startCmsListen();
|
startCmsListen();
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -164,6 +168,20 @@ public class CmsServer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化服务 前置回调
|
||||||
|
*/
|
||||||
|
public void preStartCallback(Runnable callback) {
|
||||||
|
this.preStartCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置停止服务后回调
|
||||||
|
*/
|
||||||
|
public void stopCallback(Runnable callback) {
|
||||||
|
this.stopCallback = callback;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 停止CMS服务,回收资源
|
* 停止CMS服务,回收资源
|
||||||
*/
|
*/
|
||||||
|
@ -174,6 +192,7 @@ public class CmsServer {
|
||||||
hcisupcms.NET_ECMS_StopListen(CmsHandle);
|
hcisupcms.NET_ECMS_StopListen(CmsHandle);
|
||||||
hcisupcms.NET_ECMS_Fini();
|
hcisupcms.NET_ECMS_Fini();
|
||||||
log.info("停止CMS注册服务成功!");
|
log.info("停止CMS注册服务成功!");
|
||||||
|
Optional.ofNullable(stopCallback).ifPresent(Runnable::run);
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
log.error("停止CMS注册服务失败: " + ex.getMessage(), ex);
|
log.error("停止CMS注册服务失败: " + ex.getMessage(), ex);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user