I have couple views in a Silverlight Business Application project and one domain service.
From first view, I want to be able to call a method on the service which is easy enough to do. On the service, I want to be able to raise an event when this method is called. In my second view, I want to have an event handler for this event on the service.
So far I have this for the service
public class MyService: DomainService
{
public event EventHandler<EventArgs> MyEvent;
public void SimulateSomeAction()
{
if(MyEvent!= null)
{
MyEvent(this, EventArgs.Empty);
}
}
}
And in the first view, I have
private void button1_Click(object sender, RoutedEventArgs e)
{
MyServiceContext context = new MyServiceContext();
context.SimulateSomeAction();
}
But for the second view, I don't see the event being exposed to be handled. If this is the wrong approach, How can this be achieved? I'm looking for some means to update the client view initiated by the service.
EDIT:
The two views I mention will be on different clients. Essentially I'm looking for a client-to-client communication solution via the domain service. If trying to do it via the domain service is a bad idea or not possible, please suggest as to what I should be looking into.
Currently looking into "Pushing Data to a Silverlight Client with a WCF Duplex Service" but would love it if it's possible with RIA services.
Thanks
The feature you're looking for is currently the top request on the RIA Services Wish List. From what I hear, people have been successful using the WCF Duplex Service, but I haven't seen an example.