Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7846779
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T17:42:11+00:00 2026-06-02T17:42:11+00:00

There is a Login function on a MessengerClient class. The MessengerClient class has a

  • 0

There is a Login function on a MessengerClient class. The MessengerClient class has a LoggedIn event and a IsLoggedIn property.

When Login is called on the MessengerClient class the contact list/roster is fetched via a socket from a remote server and processed, and then the client is considered logged in and IsLoggedIn will return true. The LoggedIn event is raised inside the Login function AFTER this (and thus, inside the same thread requesting the login — which I do not believe is a bad thing).

Once logged in, the client receives live updates from the remote server as they occur.

When processing the contact list/roster during login I believe the ideal design for the end user is to have ALL contact list/roster data processed BEFORE the client is considered logged in. This way, when the user receives the LoggedIn event, they are able to access contact data immediately.

For example –

Here we have the end user’s handler for the LoggedIn event.

    void MsgrLoggedIn(object sender, EventArgs a)
    {
        _msgr.Contacts.Contains("billy@bob.com"); //returns true
    }

Since all of the contact list has been processed BEFORE the client is marked as logged in, and BEFORE the LoggedIn event has been raised, the above statement returns true. Logically I believe this is what the end user would expect, as downloading and processing the contact list is part of the login operation.

Now, I also like to raise events when a contact has been added to the contact list, or added to a group. Going by the logic I’ve mentioned so far, it obviously makes no sense to raise the ContactAdded, ContactAddedToGroup etc events as the data is being processed, as this would result in the end user receiving one of those events before the MessengerClient class is even marked as being logged in.

    void MsgrContactAdded(object sender, ContactEventArgs e)
    {
        _msgr.SendMessage(e.Contact, "hello there"); // throws NotLoggedInException
    }

Which as shown above, would result in bad things happening.

So what I really need to be doing is processing contact list data, raising the logged in event, and then raising all other contact events afterwards.

For this I can just iterate over all contact objects, group objects, etc.. and raise the appropriate events.

Fine so far, right?

The problem however, is that in addition to downloading contact list data upon first login, I also have to be prepared to synchronize contact data if the client is Logged out and then logged back in.

This would involve events like ContactRemoved, ContactNameChanged, ContactRemovedFromGroup etc.

So it’s no longer quite as simple as iterating over the contacts, groups, etc, because now I have to take into account contacts that have been removed or which have had their properties changed.

So I need an alternative way of “queuing” these events to be raised after the login has taken place.

I’ve considered having classes to represent each of the synchronization events – eg.. SyncContactRemoved, SyncContactNameChanged, SyncContactAddedToGroup. With this I can process the data, and create a Sync*XXX* class for each event and add them to a list which I can then iterate after login.

I’ve also considered having methods on the objects themselves. ie Group.SyncContactsAdded, Contact.SyncNameChanged, MessengerClient.SyncContactsAdded. Then I could iterate over the contacts/groups etc after login, check these properties, raise events if necessary, and then clear them.

Finally I’ve considered having an Event class which contains an EventHandler and EventArgs. The events could be queued up in this fashion and then invoked one by one after login.

If any, which of these patterns would be considered more common practice. Or is there an alternative means to achieve this?

I apologize for such a long question, but it’s not a simple question.

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T17:42:13+00:00Added an answer on June 2, 2026 at 5:42 pm

    I ended up storing the events in a list and raising them after.

    List<SomethingEventArgs> events;
    
    foreach (SomethingEventArgs e in events)
        OnSomethingEvent(e);
    

    It’s not as glamorous as I’d have liked, but it makes a lot of sense and it works perfectly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm write a Android App which based LAMP. There is a login function in
I've written a login function in my code that will check if there are
I have this situation: There are a login page with a login form (form
I have a .NET 2005 (C#) desktop application, in which there is a login
Is there a way to login my hotmail account and send mails with a
There is a password policy in place on OpenDS preventing i.e. multiple login failures.
Is there a way to make this code work? LogonControl.java @Audit(AuditType.LOGON) public void login(String
Following is my php login script, There are one problem. If i put any
I wish there was a central, fully customizable, open source, universal login system that
Javascript SDK provides FB.login function to easily login other users. I just wonder whether

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.