Skip to content

How to determine if a broadcast event is sent by the service itself? #1201

Answered by icebob
CheaterScript asked this question in Q&A
Discussion options

You must be logged in to vote

Check the ctx.nodeID, if it's the same as local broker nodeID, it's generated by locally.

		"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);
				}
			}
		}

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@CheaterScript
Comment options

Answer selected by CheaterScript
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants