Closed fwang2002 closed 2 years ago
There were codecs in gnet v1, doing the exact same things you're talking about, however, those codecs are dropped in gnet v2, the reasons why I did that:
The built-in codecs have been deprecated and removed, to reduce the complexity and keep gnet simple. From a lot of feedback we've received, this feature does not bring convenience and benefits to users, thus, I decided to take it off from gnet. Cutting those codecs off makes the code on top of gnet more holistic and straightforward.
quoted from https://gnet.host/blog/announcing-gnet-v2/
It's better to add another method in EventHandler interface
and add an option when call gnet.Run
If splitFunc is set, then OnPacket will be called when each single complete packet is received.
SplitFunc is convenient for both splitting packet by length field and splitting packet by delimeters.