복사성공!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
class MyApplication : Application() {
override fun onCreate() {
super.onCreate()
ProcessLifecycleOwner.get().lifecycle
.addObserver(MyLifecycleObserver())
}
}
class MyLifecycleObserver : LifecycleObserver {
@OnLifecycleEvent(Lifecycle.Event.ON_START)
fun onForeground() {
// 재연결
ClientManager.getClient().networkManager.startReceiveServerInitiatedDirective()
}
@OnLifecycleEvent(Lifecycle.Event.ON_STOP)
fun onBackground() {
// 연결 종료
ClientManager.getClient().networkManager.stopReceiveServerInitiatedDirective()
}
}