How to determine if a broadcast event is sent by the service itself? #1201
Answered
by
icebob
CheaterScript
asked this question in
Q&A
-
|
Hi! I have a service that sends a broadcast event to other services in the same group after updating its content, but I want it to not receive this event itself, or be able to determine if the event initiator is itself and skip the duplicate update logic. What should I do? |
Beta Was this translation helpful? Give feedback.
Answered by
icebob
Mar 27, 2023
Replies: 1 comment 1 reply
-
|
Check the "some.thing": {
handler(ctx) {
if (ctx.nodeID == this.broker.nodeID) {
this.logger.info("Local event received", ctx.nodeID);
} else {
this.logger.info("Remote event received. Sent from", ctx.nodeID);
}
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
CheaterScript
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Check the
ctx.nodeID, if it's the same as local broker nodeID, it's generated by locally.