Solved

Multiple server callbacks to a single WCF client

Posted on 2010-09-20
5
897 Views
Last Modified: 2013-12-16
I have an application in which a single dashboard client listens to several servers, each of which controls a machine. Each of these controllers will send callbacks to a single method in the client.

In the WCF callback examples I've seen, the client is customized to a single server by means of the code generated by svcutil.exe. This won't suit for me since my client has to be able to handle a dynamically varying number of servers.

I've considered adding server code to my dashboard so that each controller sends it's messages to the client, but I'm not sure whether it's possible to be both client and server at the same time.
0
Comment
Question by:BlearyEye
  • 3
  • 2
5 Comments
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 33721284
Have you tried to subscribe your client to every server that requires to know a callback?
thus, every time a server fires a callback, your client code needs to handle it. It means that every server needs to have a publisher/subscriber mechanism as well.

Note: Callback samples (one server), but it can be use
http://idunno.org/archive/2008/05/29/wcf-callbacks-a-beginners-guide.aspx
http://www.devx.com/dotnet/Article/38814
0
 
LVL 1

Author Comment

by:BlearyEye
ID: 33721693
The main problem I see is that the examples I've looked at are pretty static (including the first link; the second one wanted me to register).

In these cases, you know in advance that you're going to be dealing with a given server and you know its address. So you run the utility to generate the C# code and config file for that particular server at its address. All this is pre-compile-time.

I need something that's dynamic, so that the servers can come and go. That's why I'm considering making the dashboard a server as well as a client, so servers can call the dashboard method.
0
 
LVL 36

Expert Comment

by:Miguel Oz
ID: 33722026
How can the client knows there is a server available?
Are these servers having the same client proxy configuration? (Basically the only difference is the server address, not the binding or the contract)

In principle you can build the client generated code using reflection, but it would be a lot work for you.
0
 
LVL 1

Author Comment

by:BlearyEye
ID: 33774472
I agree.

I've tried the idea of the Client also functioning as a server to receive messages initiated by the Servers. This seems to work and is what I'm sticking with unless a better solution presents itself.
0
 
LVL 1

Accepted Solution

by:
BlearyEye earned 0 total points
ID: 33794540
So my final arrangement is

- Servers are WCF servers AND WCF clients
- Client is WCF client AND WCF server

This handles the many servers to one client problem that WCF callback does not adequately address
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question