Closed h3ndrk closed 5 years ago
Hi,
Since packet.ArtNetPacket
is an interface, the type assertions cannot be helped. However, for any packet to be considered an packet.ArtNetPacket
at least the header is parsed. We could add a func (p *packet.ArtNetPacket) OpCode() OpCode
to the interface. This should hide all the manual parsing.
However, in practise that is just duplicating code across the packet
package instead of doing it once in the artnet
package.
I think this PR looks fine and exactly how I imagined it.
Thank you for the contribution!
This pull request extends the node by packet callbacks which let the user define own functions to handle packets.
I'm not happy with the opcode extraction and type assertions inside of the callbacks. Any ideas?