mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 22:50:13 +01:00
🎨 Alt+5 打开已有日记时不在内核伺服客户端之间同步 Fix https://github.com/siyuan-note/siyuan/issues/5617
This commit is contained in:
parent
9fb4d9da2a
commit
8ac1104d6f
5 changed files with 41 additions and 11 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue