I'm following this brilliant piece of article to dissect and understand chat using WCF. The logic is that when a user joins a chat an event handler is created for that particular user and is stored in a dictionary.
lock (syncObj)
{
if (!checkIfPersonExists(person.Name) && person != null)
{
this.person = person;
chatters.Add(person, MyEventHandler);
userAdded = true;
}
}
So multiple handlers are stored for multiple users in the service.
My question is this -
How does the service identifies the target user when a message is sent just by with the help of the event handler? I dont understand the uniqueness of the event handlers that is stored for the users. How does
handler.BeginInvoke(this, e, new AsyncCallback(EndAsync),
null);
invokes the function in the client side that has implemented the duplex client contract interface for that specific users? Which makes them connected? Sessions?
Note: I know that this may be tough to be understood without going through that article. I've tried my best to ask it in a generic way.
Regards
NLV