AlexStocks / getty

a netty like asynchronous network I/O library based on tcp/udp/websocket; a bidirectional RPC framework based on JSON/Protobuf; a microservice framework based on zookeeper/etcd
Apache License 2.0
886 stars 184 forks source link

Rft: separate udp/tcp/ws code logic #24

Open wongoo opened 4 years ago

wongoo commented 4 years ago

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.

AlexStocks commented 4 years ago

A good suggestion. I will do it in some days later.

AlexStocks commented 4 years ago

@wongoo would u try to do it? because i am so familiar with getty that i have no idea how to split them.