tags:

views:

40

answers:

4

Hello,

I have one very weird question.

There are 2 Silverlight Client 1. Admin 2. User

Now, I want a scenario wherein the Admin Silverlight can initiate a function call on the User Silverlight.

Pretty much a newbie with SL so wonder if that would be possible.

I'd appreciate any help.

Thanks

A: 

If they are both in the same frame/browser, you could call JavaScript in the first using the HtmlPage API, which could interact with the second.

So:

Silverlight control -> injects JS into HtmlPage -> JS interacts with Silverlight control 2 (assuming this is possible, please correct me if wrong) -> Silverlight control responds.

If they are in separate windows or running "out of browser", I would expect it wouldn't work.

Program.X
A: 

If the 2 instances are seperated (i.e., the admin is on one machine and the user is on another) there's no direct way to do it. However, you can rig it up with a publisher/subscriber style system.

Assumption: You have some sort of shared data store between the two, maybe a database or something.

Idea: You have the admin client write a request to this shared data store; an entry in a table, or a new file in a network share, or something. You have the user client app regularly scan this table/share for new entries, say every .5 seconds or so. When it sees the entry, it executes the requested operation, storing any return values back to the shared store. When the admin sees the return value, he knows the operation has been successfully executed.

GWLlosa
So this could be a Kinda Ajax thingy.Can you tell me one thing, if i place Silverlight Object in an Ajax Update Panel and time this Panel to refresh every 'x' seconds, will the Silverlight object also reload and execute its Page_LOad function?Thanks for your help.
James
A: 

There are a couple of options that I can think of.

  • You could implement some sort of remote procedure call via web services whereby one Silverlight app posts a request to call the method, and the other Silverlight regularly checks for method call requests.
  • If hosted on the same HTML page in a browser, you could use javascript to allow the two controls to interact.

However, direct communication between two Silverlight instances isn't supported, and while the suggestions may help to achieve something close to what you want, they don't provide a complete solution that will work in all scenarios.

Jeff Yates
+1  A: 

I suppose the applications are not in the same browser / machine, and when you describe the usage pattern as admin and user, I take that there are probably more users than admins.

You might want to take a look at duplex bindings for WCF services - this is a web service binding that allows pushing notifications to clients from the server. When all clients establish such a channel, you can implement hub-and-spoke communication between clients.

This blog post gives a good receipt for getting started: http://silverlightforbusiness.net/2009/06/23/pushing-data-from-the-server-to-silverlight-3-using-a-duplex-wcf-service/

GreenIcicle
Thanks.I should try this out!
James