[英]send an object through ObjectOutputStream only one client
Suppose we have one server and two or more clients connected to it. 假设我们有一台服务器和两个或多个客户端相连。 The server wants to send through
ObjectOutputStream
an object so use it and open the server stream output using the method getOutputStream()
. 服务器希望通过
ObjectOutputStream
发送一个对象,因此可以使用它并使用方法getOutputStream()
打开服务器流输出。 The server wants to send this file only to one determinate client that have one field setted in a certain way. 服务器只希望将此文件发送给以某种方式设置了一个字段的一个确定的客户端。 the server maintains in a list the object client with all its field.
服务器在列表中维护对象客户端及其所有字段。 The server wants to send an object only to a client who has a field setted in a certain way.So the server iterates the list and after find that client send to it the object.but how can determinate into the net which is the client?
服务器只想将对象发送给具有以某种方式设置了字段的客户端,因此服务器对列表进行迭代,然后找到该客户端向其发送对象,但是如何确定进入客户端的网络呢?
让每个客户端在其更改时将其状态发送到服务器,或者将对象发送给所有客户端,如果它们的状态为false,则让他们忽略该消息。
If you really want to do this, you will need multiple connections and/or multiple round-trips. 如果确实要执行此操作,则将需要多个连接和/或多个往返。 Either the clients have to actively sent their status to the server, or the server has to ask them.
客户端要么必须主动将其状态发送到服务器,要么服务器必须询问他们。 Or, thirdly, the server could send them all the same message, but with a flag included that means 'only pay attention if you are 'free'.'
或者,第三,服务器可以向他们发送相同的消息,但其中包含一个标志,表示“仅在您有空时注意”。
Really, you'd be better off learning to use a message queue system. 确实,您最好学习使用消息队列系统。 You could use, for example, Apache ActiveMQ, and you could use Spring/JMS or Apache CXF Soap over JMS.
例如,您可以使用Apache ActiveMQ,也可以在JMS上使用Spring / JMS或Apache CXF Soap。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.