wind-c / comqtt

A lightweight, high-performance go mqtt server(v3.0|v3.1.1|v5.0) supporting distributed cluster
MIT License
869 stars 50 forks source link

Dropping messages in OnPublish #76

Closed borud closed 8 months ago

borud commented 8 months ago

I have been trying to figure out if there is a way to drop messages in the OnPublish hook. Both to drop them silently (ie. let the client believe that the message was published normally) and to drop them with some error state sent back to the client.

borud commented 8 months ago

Nevermind, I figured it out.

For the benefit of others wondering the same: this can be done by setting the field Ignore in packets.Packet to true.