jsimonetti / go-artnet

This package attempts to implement the Art-Net 4 specification from (c) Artistic Licence Holding Ltd.
MIT License
33 stars 20 forks source link

Node Packet Callbacks #18

Closed h3ndrk closed 5 years ago

h3ndrk commented 5 years ago

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?

jsimonetti commented 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.

jsimonetti commented 5 years ago

Thank you for the contribution!