mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-03-06 12:50:16 +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
|
|
@ -24,10 +24,11 @@ import (
|
|||
type PushMode int
|
||||
|
||||
const (
|
||||
PushModeBroadcast PushMode = 0 // 广播
|
||||
PushModeSingleSelf PushMode = 1 // 自我单播
|
||||
PushModeBroadcastExcludeSelf PushMode = 2 // 非自我广播
|
||||
PushModeBroadcastExcludeSelfApp PushMode = 4 // 非自我应用广播
|
||||
PushModeBroadcast PushMode = 0 // 所有应用所有会话广播
|
||||
PushModeSingleSelf PushMode = 1 // 自我应用会话单播
|
||||
PushModeBroadcastExcludeSelf PushMode = 2 // 非自我会话广播
|
||||
PushModeBroadcastExcludeSelfApp PushMode = 4 // 非自我应用所有会话广播
|
||||
PushModeBroadcastApp PushMode = 5 // 单个应用内所有会话广播
|
||||
PushModeNone PushMode = 10 // 不进行 reload
|
||||
)
|
||||
|
||||
|
|
|
|||
|
|
@ -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