🎨 Alt+5 打开已有日记时不在内核伺服客户端之间同步 Fix https://github.com/siyuan-note/siyuan/issues/5617

This commit is contained in:
Liang Ding 2022-10-21 11:35:02 +08:00
parent 9fb4d9da2a
commit 8ac1104d6f
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
5 changed files with 41 additions and 11 deletions

View file

@ -226,6 +226,8 @@ func PushEvent(event *Result) {
broadcastOthers(msg, event.SessionId)
case PushModeBroadcastExcludeSelfApp:
broadcastOtherApps(msg, event.AppId)
case PushModeBroadcastApp:
broadcastApp(msg, event.AppId)
case PushModeNone:
}
}
@ -275,6 +277,21 @@ func broadcastOtherApps(msg []byte, excludeApp string) {
})
}
func broadcastApp(msg []byte, app string) {
sessions.Range(func(key, value interface{}) bool {
appSessions := value.(*sync.Map)
appSessions.Range(func(key, value interface{}) bool {
session := value.(*melody.Session)
if sessionApp, _ := session.Get("app"); sessionApp != app {
return true
}
session.Write(msg)
return true
})
return true
})
}
func broadcastOthers(msg []byte, excludeSID string) {
sessions.Range(func(key, value interface{}) bool {
appSessions := value.(*sync.Map)