开发者

Chat Server with Java & Netty

开发者 https://www.devze.com 2023-04-09 23:50 出处:网络
I want to implement a Chat Server with Java and Netty. My question is: should I make all the work in Netty\'s connection handler?

I want to implement a Chat Server with Java and Netty. My question is: should I make all the work in Netty's connection handler? For "all the work" I mean for example: to do the login 开发者_如何学Python( so with mysql connection ), eventually to send message, to log informations..


I think a more robust design would be to make a system that works without Netty and then use Netty's connection handler to go between the two. This way, if you decide to move away from Netty in the future, you can do so with minimal rewiring.


If you put all that functionality into interface-based POJOs, rather than a Netty connection handler, you'll find it easier to test it without having to fire up Netty.

Once you have all those objects working and tested, then give them to a connection handler and let them do the work. The connection handler just orchestrates your POJOs to fulfill its requests.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号