本文介绍了如何用Netty发送对象?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何通过Netty从服务器端发送Bean并在客户端接收此Bean?当我发送简单的整数消息inputstream时,它可以成功工作,但是我需要发送bean.
How to send bean from server side and receive this bean in the client side by Netty? When I send simple integer message, inputstream, it works successfully but I need to send bean.
推荐答案
如果您在客户端和服务器端使用netty,则可以使用Netty ObjectDecoder 和来发送和接收对象.
If you are using netty at client and server side then you can use the Netty ObjectDecoder and ObjectEncoder in your ChannelPipeline
to send and receive objects.
看看网络乒乓示例.该代码已经过时,但是您将获得使用对象的总体思路.
Take a look at the netty ping pong example which does this. The code is bit out of date, but you will get the general idea on working with objects.
这篇关于如何用Netty发送对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!