|
@@ -226,6 +226,8 @@ func PushEvent(event *Result) {
|
|
broadcastOthers(msg, event.SessionId)
|
|
broadcastOthers(msg, event.SessionId)
|
|
case PushModeBroadcastExcludeSelfApp:
|
|
case PushModeBroadcastExcludeSelfApp:
|
|
broadcastOtherApps(msg, event.AppId)
|
|
broadcastOtherApps(msg, event.AppId)
|
|
|
|
+ case PushModeBroadcastApp:
|
|
|
|
+ broadcastApp(msg, event.AppId)
|
|
case PushModeNone:
|
|
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) {
|
|
func broadcastOthers(msg []byte, excludeSID string) {
|
|
sessions.Range(func(key, value interface{}) bool {
|
|
sessions.Range(func(key, value interface{}) bool {
|
|
appSessions := value.(*sync.Map)
|
|
appSessions := value.(*sync.Map)
|