简体   繁体   中英

Send data from server to a specific client

I have a little problem in my multi-client/server application. I need to send specific data to a single client from the server but I don't know how to do it. I temporarily solved this problem by adding an header with the client specification. But it isn't the best solution because the server every time send the data to all the client connected. How can I solve this problem?

I had a similar problem. I added a field to the web service containing a guid. Obviously all the clients pole the service at regular intervals to ascertain they need new data. If a client needs to be sent extra data, when it makes a regular request to the server the server reads it's client id and creates the appropriate guid which it returns in it's regular data feed. When the client reads the guid field as not null, it calls the second web method, using the guid as an argument. The second web method reads the guid and uses it to look up then return the extra required data. An alternative would be to use push technology by keeping the connection open and keeping the client in permanent state of 'loading'. When there is additional client specific data, the server can inject some code, eg javascript, into the permanently open request which will then request the new data from the server. Based on my experiences of implementing push technology would leads me to advising you try the former method above. The only other option would be to install some kind of server application on your client to receive pushed data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM