Skip to content

Commit

Permalink
only dispatcher update message to definitions owner when update origi…
Browse files Browse the repository at this point in the history
…niates to a non-owner
  • Loading branch information
vitaminwater committed Jul 23, 2015
1 parent 3ea9b09 commit 0da4a81
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions dispatcher/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,22 +123,29 @@ func (dispatcher *Dispatcher) removeConnectionAt(index int) {
}

func (dispatcher *Dispatcher) dispatchUpdate(from int, update *Update) {
fromConnection := dispatcher.connections[from]
fromOwner := false
if _, err := fromConnection.definitions.GetDefinitionForObjectID(update.ObjectID); err == nil {
fromOwner = true
}
mainLoop:
for i, connection := range dispatcher.connections {
if i == from {
continue
}
subscribed := false
for _, objectID := range connection.subscriptions {
if objectID == update.ObjectID {
subscribed = true

if fromOwner == true {
for _, objectID := range connection.subscriptions {
if objectID == update.ObjectID {
connection.InChan <- *update
continue mainLoop
}
}
}
if subscribed == false {
if _, err := connection.definitions.GetDefinitionForObjectID(update.ObjectID); err != nil {
continue
} else {
if _, err := connection.definitions.GetDefinitionForObjectID(update.ObjectID); err == nil {
connection.InChan <- *update
}
}
connection.InChan <- *update
}
}

Expand Down

0 comments on commit 0da4a81

Please sign in to comment.