Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF service send data to client

Is possible to send data from WCF service to client without request ? For example in WCF I have function which in loop send data. How can I make that functionality ?

like image 292
Szymson Avatar asked Mar 13 '23 04:03

Szymson


2 Answers

This can be achieved with a Full Duplex contract. Where you will hold reference to the client in the service instance and then you can use the CallbackContract to send messages to the client who has registered to the service.

Answering this question with a clear code example would require more of a blog post than stackoverflow reply. So just linking a very simplified example which you can find from here.

like image 160
Janne Matikainen Avatar answered Mar 18 '23 18:03

Janne Matikainen


You could solve this with "long-polling"

This could help you: How do I implement basic "Long Polling"?

But there is the problem, that the client has to send a request first.

like image 36
Patrick Avatar answered Mar 18 '23 18:03

Patrick