English 中文(简体)
查询清单/名册下载/信使图书馆同步化的理想设计模式
原标题:Ideal design pattern for contact list/roster download/synchronization in a Messenger library

MessengerClient上任。 MessengerClient 等值有 在活动和上 在财产中。

LoginMessengerClient上打字时,联系名单/名册通过边远服务器和经过处理的袖珍,然后客户被视为挂在册, 贴在<<<><>>上>。 www.un.org/spanish/ga 在中,在Login功能 AFTER(因此,在要求登录的同一条线内——我认为这不是一件坏事)内提出。

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

在记录过程中处理联系清单/名册 我认为,终端用户的理想设计是掌握所有接触清单/名册数据,而客户则被视为有缺陷。 这样,当用户收到路标时 在活动中,他们能够立即获得联系数据。

For example -

这里,我们有“LobedIn”活动的终端用户手。

    void MsgrLoggedIn(object sender, EventArgs a)
    {
        _msgr.Contacts.Contains("[email protected]"); //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.

现在,我还要提出在联系名单上增加联系或加入小组时发生的事件。 根据迄今为止提到的逻辑一,在数据处理过程中,显然没有必要提出ContactAdded、ContactAddedTogroup等事件,因为这将导致终端用户在SerClient类别甚至被贴上标签之前收到其中一项事件。

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

如上所示,这将造成坏事。

因此,我确实需要做的是处理联络名单数据,提高所记录的事件,然后在其后提出所有其他联系活动。

为此,我只能对所有接触物体、团体目标等进行播音,并提出适当的事件。

至今为止的罚款?

然而,问题在于,除了在第一日志上下载接触清单数据外,如果客户被拖出,然后被拖回,我还必须准备同步进行联系数据。

这将涉及诸如联系人、联系人、联系人等活动。

因此,它不再简单地重复接触、团体等,因为现在我必须考虑到已经拆除或改变其财产的联系。

因此,我需要一种替代方式,即在标志发生之后,才能提出这些事件。

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.

我也考虑对物体本身有办法。 页: 1 Group.SyncContacts 此外,SyncNameChanged,SierClient.SyncContactsAdded。 然后,我可以自行处理伐木后的接触/小组等,检查这些财产,必要时提出事件,然后予以清除。

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.

如果是的话,这些模式中哪一种将被视为较为常见的做法。 或者是否有其他办法实现这一目标?

我对这一长期问题表示歉意,但这不是一个简单的问题。

成就

最佳回答

我最后把这些事件列入清单,然后提出。

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.

问题回答

每个联系人都有自己的联系清单。

public class Contact
{
  List<Contact> Contacts;
}

每一联系人都有自己的活动(财产被篡改、gged陷、不管怎样)。

public class Contact
{
  List<Contact> Contacts;
  public event OnPropertyChanged;
}

如果接触记录显示,该联系人将登记在其联系清单中各联系人的所有活动。

public void LogIn
{
  //Load Contact List for User - Do other stuff
  foreach(Contact c in Contacts)
    c.PropertyChanged += new PropertyChangedEventHandler(ContactPropertyChanged);
}

现在,如果接触名单上出现一些事情,那些在名单上有这种联系的人就会参加活动。

public void ChangeProperty
{
  //Change Property and raise event!
}

我认为,你需要研究各国的设计模式。 2. 认为客户有不同的状态,例如:

该邦的Login邦将开展一些特别活动,如LoginFailed或LoginSucceed,而且这一状态只能提供一种方法。

说明用户将接受电文并将其发送小组。

不管你们需要什么。

因此,你的客户阶层将实施特别的国家听众界面,这将产生有效的活动(活动只是一个接口方法电话)。

这样,你就可以将不同国家的逻辑分给不同阶层。 您将在国内改变现状,这样,图书馆的用户将无法打上任何黑板,使你的图书馆无法工作。

I think that it is the best solution for the asynchronous communication implementation. Consider two state machines in client and server side.

实际上,这是很多法典,所以我只是给你这个概念。

http://en.wikipedia.org/wiki/State_pattern

其中哪一种模式将被视为较为常见的做法。 或者是否有其他办法实现这一目标?

因此,如果我这样直截了当,你要问一下在某种接触中发生的一切事件,而第一个是线不定的? 因此,联系人A在联系名单上有联系人B,但联系人A目前已经离线。 现在的联系 B 改变他的形象,请询问联系A的活动(ContactNameChanged等)。

我没有这样做。 我只储存某种合成物(时间为罚款),表明联系A收到联系B的数据。 然后,每个联系人都有一个<代码>LastModised 的财产,与您的同yn相比。 如果自您上次总结以来做了一些修改,则要求获得经修改的接触详情。

为了删除接触,你只能把两个清单混为一谈。 客户认为,有一个联系清单是目前的清单,另一个是服务器的最新清单。 相比之下,这将导致添加和删除,在通过这一清单时,你也可以比较上文提及的<代码>经修改的<<>代码>。





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签