🎨 Data synchronization supports the multi-kernel online perception https://github.com/siyuan-note/siyuan/issues/8518

This commit is contained in:
Daniel 2023-06-11 23:29:09 +08:00
parent 3579a45831
commit 49499e13b6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 17 additions and 1 deletions

View file

@ -372,6 +372,12 @@ func SetSyncEnable(b bool) {
func SetSyncPerception(b bool) {
Conf.Sync.Perception = b
Conf.Save()
if b {
connectSyncWebSocket()
} else {
closeSyncWebSocket()
}
return
}
@ -641,6 +647,16 @@ var (
onlineKernelsLock = sync.Mutex{}
)
func closeSyncWebSocket() {
webSocketConnLock.Lock()
defer webSocketConnLock.Unlock()
if nil != webSocketConn {
webSocketConn.Close()
webSocketConn = nil
}
}
func connectSyncWebSocket() {
defer logging.Recover()