I have a winform application and a wcf service. My intention is, when my winform application sends a request message to wcf service, the service has to store the details of the client request and after sometime, wcf will return a call back to the winform [client] application.
Suppose that there will be 10 such clients that sends a request to this wcf service and after 5 minutes the service will send a call back message to each client by sending a "hi" message.
My service implementation is like this.
[ServiceContract(SessionMode = SessionMode.Required, CallbackContract =
typeof(IServiceCallBacks))]
public interface IService
{
[OperationContract]
void Connect(User user);
}
And my call back method is as shown below
public interface IServiceCallBacks
{
[OperationContract(IsOneWay = true)]
void ContactsUpdated(List<Contact> updatedContacts);
}
And here is the implementation
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
public class Service : IService
{
List<User> users = new List<User>();
public Service()
{
}
public void Connect(User user)
{
users.Add(user);
}
Is this correct way ? How I can send a notification to each client from the service ?