there are lot of code that need to consider what kind of the connection, tcp or udp or ws, which let the code logic complex.
So suggest to separate udp/tcp/ws code logic.
For example, a interface can be defined:
type ProtocolHandler interface {
handleLoop()
handlePackage()
}
Assign matched ProtocolHandler to a protocol, not check the type of connection in handler logic, make the logic simple.
there are lot of code that need to consider what kind of the connection, tcp or udp or ws, which let the code logic complex.
So suggest to separate udp/tcp/ws code logic.
For example, a interface can be defined:
Assign matched ProtocolHandler to a protocol, not check the type of connection in handler logic, make the logic simple.