TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
nishant singh
NA
5
0
Advice on my WCF event logic
Aug 18 2009 8:24 AM
I have to make a event notification service in WCF. i made it using callback mechanism of WCF. when the service is running all the clients can subscribe to the service and recieve a Broadcast message from server whenever any event occurs.
According to my implementation there is a Delegate at server side:
public delegate void CallbackDelegate<T>(T t);
public static CallbackDelegate<string> MessageReceived; to which all clients subscribe like:
// these two lines subscribes the client to a single event and whenever event occurs all client recieves the data.
IEventSystemCallback callback = OperationContext.Current.GetCallbackChannel<IEventSystemCallback>();
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.
Reply
Answers (
0
)
To modify xml
Setting URL on a WebBrowser object