According to my implementation there is a Delegate at server side:
public delegate void CallbackDelegate
public static CallbackDelegate
// these two lines subscribes the client to a single event and whenever event occurs all client recieves the data.
IEventSystemCallback callback = OperationContext.Current.GetCallbackChannel
MessageReceived += callback.OnMessageReceived;
but my requirement is to filter the data based on the IP of the client and send only selected data based on some other parameters.
I thought of a logic according to which only one client will subscribe at a time to the Delegate so that he only will receive the data.
so what i did is: checked the coming data from the server method which is suppose to raise the Delegate, found the correct client and subscribe it , send the message and then again unsubscribe it like this:
if (readerName == listReaderNames[i].ToString()) // my filtering to get the correct client
{
MessageReceived += objCall.OnMessageReceived;
string message ="Sample Data";
if (MessageReceived != null)
{
MessageReceived(message); // sends the message to the subscribed client
MessageReceived -= objCall.OnMessageReceived; // removes the subscription so that next time only
one client will be there.
}
}
is this the correct approach or is there any other better way to achieve non Broadcast client notification through WCF.
please give me some idea.
Replies
Know the answer? Post it — somebody with the same question will find it here.