I use WCF and I put the chat room in my C# program. Therefore, I need to be able to send information from the server to clients on two events -
- When a user connects / disconnects, I update the list of connected users and send them to all clients for display in TextBlock
- When a user sends a message, I need the server to send this message to all clients
Therefore, I am looking for advice on the best way to implement it. I was going to use netTcpBinding for duplex callbacks for clients, but then I ran into some problems regarding the fact that you cannot call the client back if the connection is closed. I need to use percall instances for scalability. I was informed in this thread that I should not leave communications open, as this "significantly limits scalability" - WCF duplex callbacks, how to send a message to all clients?
However, I looked at the book “Programming WCF Services,” and the author seems to state that this is not a problem, because “between calls, the client contains a link to a proxy server that does not have an actual object at the end of the wire. This means that you can get rid of the expensive resources that an instance of a service takes long before the client closes the proxy server "
- So, what’s right, is it good to keep proxies open on clients?
- But even if it’s good, it leads to another problem. If service instances are destroyed between calls, how can they perform duplex callbacks to update clients? Regarding percall instances, WCF Services author says: "Since the object will be discarded after the method returns, you should not unscrew the background threads or send asynchronous calls back to the instance"
- Would it be better if customers polled the service for updates? I would suggest that this is much more inefficient than two-way callbacks, clients can end up polling the service 50 times more often than using two-way callbacks. But maybe there is no other way? Will it be scalable? I have envisioned several hundred concurrent users.
source share