Skip to content
This repository has been archived by the owner on Feb 22, 2024. It is now read-only.

Commit

Permalink
Whisper Dispatch
Browse files Browse the repository at this point in the history
  • Loading branch information
AnatoleAM committed Mar 15, 2023
1 parent 8107517 commit 7719777
Showing 1 changed file with 12 additions and 10 deletions.
22 changes: 12 additions & 10 deletions internal/app/connection/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,19 @@ const (
func (h handler) OnDispatch(gctx global.Context, msg events.Message[events.DispatchPayload]) bool {
var matches []uint32

if msg.Data.Whisper == "" || msg.Data.Whisper != h.conn.SessionID() {
// Filter by subscribed event types
ev, ok := h.conn.Events().Get(msg.Data.Type)
if !ok {
return false // skip if not subscribed to this
}
if msg.Data.Whisper != "" && msg.Data.Whisper != h.conn.SessionID() {
return false // skip if event is whisper not for this session
}

matches = ev.Match(msg.Data.Conditions)
if len(matches) == 0 {
return false
}
// Filter by subscribed event types
ev, ok := h.conn.Events().Get(msg.Data.Type)
if !ok {
return false // skip if not subscribed to this
}

matches = ev.Match(msg.Data.Conditions)
if len(matches) == 0 {
return false
}

// Dedupe
Expand Down

0 comments on commit 7719777

Please sign in to comment.