Reputation: 108957
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
Upvotes: 1
Views: 397
Reputation: 2029
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.
Upvotes: 1
Reputation: 9326
Are those code snippets accurate?
I don't see how your first view is seeing the Simulate method.
If you want to add functionality to the generated contexts or models, look at using a partial class. So in the Silverlight project add a class like
namespace MyProject.Web.Services {
public partial class MyContext {
// Add new methods, events etc here
}
}
Upvotes: 0