Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can you send data to clients from a WCF service without the clients having to call the service?

Tags:

c#

wcf

p2p

Say I want to write a peer to peer chat application. And I use a WCF service as the server that the clients 'log in' to so that they can find each other's ip addresses and ports.

Well, say also I have a textbox in my client application that display all users that are online. Everytime users log in or out I want to update this 'Who's online' textbox so that only the currently online users are shown.

So the server needs to send information out to all clients once a user logs in or out. But it seems WCF can only send data when responding to requests....

Am I missing something here, is WCF able to handle this situation?

like image 588
Jim_CS Avatar asked Jan 24 '26 10:01

Jim_CS


2 Answers

There are several approaches to this problem, these would probably be the most common:

  1. Use publish/subscribe, like in this good article.
  2. Keep all the currently logged users in a storage - a database or whatever you'd prefer, and query it from the users' side.
like image 94
oleksii Avatar answered Jan 25 '26 23:01

oleksii


I think you need a duplexing service.

like image 35
Josh C. Avatar answered Jan 25 '26 23:01

Josh C.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!