ContactManager ContactManager ContactManager ContactManager Class

정의

Windows 주소록에 유지되는 PeerContact 개체의 컬렉션을 나타냅니다.Represents a collection of PeerContact objects which persist in a Windows Address Book.

public ref class ContactManager sealed : IDisposable
public sealed class ContactManager : IDisposable
type ContactManager = class
    interface IDisposable
Public NotInheritable Class ContactManager
Implements IDisposable
상속
ContactManagerContactManagerContactManagerContactManager
구현

예제

다음 예제 코드를 열거 하는 방법을 보여 줍니다는 PeerNearMe 로 추가 하 고는 PeerContact 로컬 ContactManager:The following example code illustrates how to enumerate a PeerNearMe and add it as a PeerContact to the local ContactManager:

   // Displays all contacts and asssociated peer endpoints (PeerEndPoint) in the PeerContactCollection.
   private static void DisplayContacts(PeerContactCollection peerContactsCollection)
   {
       if (peerContactsCollection == null ||
           peerContactsCollection.Count == 0)
       {
           Console.WriteLine("No contacts to display. To add a contact select option 0 from the menu.");
       }
       else
       {
           foreach (PeerContact pc in peerContactsCollection)
           {
               Console.WriteLine("The contact is: {0}", pc.DisplayName);
               DisplayEndpoints(pc.PeerEndPoints);
           }
       }
       return;
   }
   
   //------------------------------------------------------------------------------------------------------
   //------------------------------------------------------------------------------------------------------
   // Displays all peer end points (PeerEndPoint) in the PeerEndPointCollection.

   private static void DisplayEndpoints(PeerEndPointCollection endpointCollection)
   {
       if (endpointCollection == null ||  endpointCollection.Count == 0)
           Console.WriteLine("No peer endpoints in the collection to display.");
       else
       {
           foreach (PeerEndPoint pep in endpointCollection)
           {
               Console.WriteLine("PeerEndPoint is: {0}", pep);
               Console.WriteLine("PeerEndPoint data is:\n  Name: {0}\n EndPoint IP address: {1}\n . Port: {2}\n",
                   pep.Name,
                   pep.EndPoint.Address,
                   pep.EndPoint.Port);
           }
       }
       return;
   }
   
   //------------------------------------------------------------------------------------------------------
   //------------------------------------------------------------------------------------------------------
   //List PeerNearMe objects that may be added as contacts.
   
   private static void AddContact()
   {
       PeerNearMeCollection pnmc = null;
       PeerContactCollection peerContacts = null;            
       bool peerNameFound = false;

       PeerApplication application = null;

       try
       {
           Console.WriteLine("Listing the existing contacts...");
           peerContacts = PeerCollaboration.ContactManager.GetContacts();
       }
       catch (PeerToPeerException p2pEx)
       {
           Console.WriteLine("The Peer Collaboration Infrastructure is not responding to the contact enumeration request: {0}", p2pEx.Message);
       }
       catch (Exception ex)
       {
           Console.WriteLine("An unexpected error occurred while attempting to obtain the contact list: {0}", ex.Message);
       }

       DisplayContacts(peerContacts);

       try
       {
           //Adds one of the PeerNearMe objects as a contact.                               
           pnmc = GetPeersNearMe();
           Console.WriteLine("Please enter the nickname of the peer you wish to add as a contact:");
           string peerNameToAdd = Console.ReadLine();

           application = RegisterCollabApp();

           foreach (PeerNearMe pnm in pnmc)
           {
               PeerInvitationResponse res = null;
               if (pnm.Nickname.Contains(peerNameToAdd))
               {
                   peerNameFound = true;
                   if (!peerContacts.ToString().Contains(pnm.Nickname))
                   {
                       Console.WriteLine("Adding peer {0} to the contact list.", pnm.Nickname);
                       pnm.AddToContactManager();
                   }
                   else
                   {
                       Console.WriteLine("This peer already exists in your contact list.");
                       Console.WriteLine("Sending invitation using the Contact structure instead of the PeerNearMe.");
                       foreach (PeerContact pc in peerContacts)
                       {
                           if (pc.Nickname.Equals(pnm.Nickname))
                           {
                               res = pnm.Invite(application, "Peer Collaboration Sample", application.Data);
                               if (res.PeerInvitationResponseType == PeerInvitationResponseType.Accepted)
                               {
                                   Console.WriteLine("Invitation to contact succeeded.");
                               }
                               else
                               {
                                   Console.WriteLine("Invitation to contact {0}.", res.PeerInvitationResponseType);
                               }
                           }
                       }

                   }
               }
           }

           if (!peerNameFound)
           {
               Console.WriteLine("No such peer exists near you. Cannot add to contacts.");
               return;
           }

           peerContacts = PeerCollaboration.ContactManager.GetContacts();

           Console.WriteLine("Listing the contacts again...");
           DisplayContacts(peerContacts);

       }
       catch (Exception ex)
       {
           Console.WriteLine("Error adding a contact: {0}", ex.Message);
       }
       finally
       {
           application.Dispose();
       }
       return;
   }

설명

이 클래스에 대 한 참조를 반환한 이후 없는 public 생성자에는 PeerCollaboration 클래스입니다.This class has no public constructors, since a reference to it is returned by the PeerCollaboration class.

와 연결 된 주소록 PeerContact 관리는 원격 피어 호스트 피어와 연결 된 이벤트가 포함 됩니다.Address books that are associated with PeerContact management include those associated with the host peer and a remote peer. 어느 쪽 컴퓨터 든; 다른 동료와 공동 작업 피어 원격 피어의 하지만 하지 호스트 피어에 로컬인 경우에 추가할 수 있습니다는 ContactManager 호스트 피어입니다.Either computer may collaborate with other peers; when a peer is local to the remote peer but not the host peer, it can be added to the ContactManager of the host peer. 특정 작업을 ContactManager 클래스와 같이 AddContactDeleteContact, 원격 피어의 Windows 주소록에서 수행 하 고 연결 된 작업에 상관 관계를 지정 합니다.Certain operations on the ContactManager class, such as AddContact and DeleteContact, correlate to the associated operations being performed on the Windows Address book of the remote peer.

호스트 피어에 대 한이 영구 스토리지에 액세스할 수 있습니다 PeerContact 피어를 참여 하고자 하는 애플리케이션과 연결 될 수 있는 정보입니다.The host peer has access to this persistent storage for PeerContact information, which can be associated with the applications in which a peer intends to participate. A PeerApplication 자체의 사용자로 식별할 수 있습니다는 ContactManager 컴퓨터에 영구 저장소입니다.A PeerApplication can identify itself as a user of a ContactManager persistent store on a computer.

속성

LocalContact LocalContact LocalContact LocalContact

로컬 피어를 나타내는 PeerContact를 가져옵니다.Gets the PeerContact representing the local peer.

SynchronizingObject SynchronizingObject SynchronizingObject SynchronizingObject

이 속성 값이 설정되면 비동기 작업의 결과로 발생되지 않는 모든 이벤트에는 특정 SynchronizingObject를 만든 스레드에서 다시 호출된 이벤트 처리기가 연결됩니다.When this property value is set, all events not fired as the result of an asynchronous operation will have the associated event handlers called back on the thread that created the specific SynchronizingObject.

메서드

AddContact(PeerContact) AddContact(PeerContact) AddContact(PeerContact) AddContact(PeerContact)

지정된 PeerContact를 로컬 피어의 ContactManager에 추가합니다.Adds the specified PeerContact to the ContactManager of the local peer.

CreateContact(PeerNearMe) CreateContact(PeerNearMe) CreateContact(PeerNearMe) CreateContact(PeerNearMe)

지정된 PeerContact 개체에 대해 PeerNearMe 인스턴스를 만듭니다.Creates a PeerContact instance for the specified PeerNearMe object.

CreateContactAsync(PeerNearMe, Object) CreateContactAsync(PeerNearMe, Object) CreateContactAsync(PeerNearMe, Object) CreateContactAsync(PeerNearMe, Object)

지정된 PeerNearMe 개체에 대해 연락처 인스턴스를 만듭니다.Creates a contact instance for the specified PeerNearMe object.

DeleteContact(PeerContact) DeleteContact(PeerContact) DeleteContact(PeerContact) DeleteContact(PeerContact)

로컬 피어의 ContactManager에서 지정된 PeerContact를 제거합니다.Removes the specified PeerContact from the ContactManager of the local peer.

DeleteContact(PeerName) DeleteContact(PeerName) DeleteContact(PeerName) DeleteContact(PeerName)

로컬 피어의 ContactManager에서 지정된 PeerName과 연결된 PeerContact를 제거합니다.Removes the PeerContact associated with the specified PeerName from the ContactManager of the local peer.

Dispose() Dispose() Dispose() Dispose()

해당 ContactManager 개체에서 사용하는 리소스를 모두 해제합니다.Releases all resources used by the ContactManager object.

Equals(Object) Equals(Object) Equals(Object) Equals(Object)

지정한 개체와 현재 개체가 같은지 여부를 확인합니다.Determines whether the specified object is equal to the current object.

(Inherited from Object)
GetContact(PeerName) GetContact(PeerName) GetContact(PeerName) GetContact(PeerName)

지정된 PeerContact에 대한 PeerName 개체를 반환합니다.Returns the PeerContact object for the specified PeerName.

GetContacts() GetContacts() GetContacts() GetContacts()

원격 피어의 PeerContactCollection에 있는 모든 대화 상대를 포함하는 ContactManager을 반환합니다.Returns a PeerContactCollection that contains all contacts within the ContactManager of the remote peer.

GetHashCode() GetHashCode() GetHashCode() GetHashCode()

기본 해시 함수로 작동합니다.Serves as the default hash function.

(Inherited from Object)
GetType() GetType() GetType() GetType()

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone() MemberwiseClone() MemberwiseClone() MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(Inherited from Object)
ToString() ToString() ToString() ToString()

현재 개체를 나타내는 문자열을 반환합니다.Returns a string that represents the current object.

(Inherited from Object)
UpdateContact(PeerContact) UpdateContact(PeerContact) UpdateContact(PeerContact) UpdateContact(PeerContact)

PeerContact와 연결된 데이터를 업데이트합니다.Updates the data associated with the PeerContact.

이벤트

ApplicationChanged ApplicationChanged ApplicationChanged ApplicationChanged

PeerApplicationPeerContact와 연결된 ContactManager이 변경될 때마다 발생합니다.Raised whenever a PeerApplication associated with a PeerContact in the ContactManager has changed.

CreateContactCompleted CreateContactCompleted CreateContactCompleted CreateContactCompleted

CreateContact(PeerNearMe) 메서드가 완료될 때마다 발생합니다.Raised whenever a CreateContact(PeerNearMe) method has completed.

NameChanged NameChanged NameChanged NameChanged

PeerNamePeerContact와 연결된 ContactManager이 변경될 때마다 발생합니다.Raised whenever the PeerName associated with a PeerContact in the ContactManager has changed.

ObjectChanged ObjectChanged ObjectChanged ObjectChanged

대화 상대의 등록된 PeerObject 개체에 포함된 개체가 변경될 때마다 발생합니다.Raised whenever an object within a contact's registered PeerObject objects has changed.

PresenceChanged PresenceChanged PresenceChanged PresenceChanged

PeerContact에 포함된 ContactManager의 현재 상태가 변경될 때마다 발생합니다.Raised whenever the presence status of a PeerContact in the ContactManager has changed.

SubscriptionListChanged SubscriptionListChanged SubscriptionListChanged SubscriptionListChanged

구독한 대화 상대 목록이 변경되면 발생합니다.Raised when the list of subscribed contacts changes.

적용 대상

추가 정보