Share via


PeerNameRegistration.Start 메서드

정의

PeerNameCloud에 등록합니다. EndPointCollection을 지정하지 않으면 Port 속성으로 지정된 포트 값과 함께 자동 주소 선택이 사용됩니다.

public:
 void Start();
[System.Security.SecurityCritical]
public void Start ();
[<System.Security.SecurityCritical>]
member this.Start : unit -> unit
Public Sub Start ()
특성

예외

PeerName 속성이 null로 설정되어 있습니다.

이전에 이 개체에 Dispose()가 호출된 경우

  • 지정된 PeerName이 이미 등록된 경우 Update() 메서드는 등록을 업데이트하는 데 사용해야 합니다.

  • 원격 피어가 지정된 PeerName에 대한 Authority를 소유하지 않는 경우

  • PeerName 또는 Data 둘 다 지정되지 않은 경우. 하나 이상을 제공해야 합니다.

  • 메시지 또는 데이터 요소가 유효하지 않은 경우 또는 UseAutoEndPointSelection이 설정되어 있지 않고 데이터 blob 또는 IPEndPoint가 지정되지 않은 경우

예제

다음 코드 예제는 PeerName 하 고 지정 된 메타 데이터와 함께 등록 합니다.

// Creates a PeerName and registers it along with the metadata specified
// The parameters used to register the name are static types that are set
// from user input (command-line or user dialog).
// These parameters include the following:
//   static String peerName
//   static PeerNameType peerNameType
//   static int portNumber
//   static String comment
//   static Cloud cloudName

public static void CreateAndPublishPeerName()
{
    try{
        // Creates a the PeerName to register using the classifier and type provided
        PeerName peerName = new PeerName(peerNameClassifier, peerNameType);

        // Create a registration object which represents the registration
        // of the PeerName in a Cloud
        PeerNameRegistration peerNameRegistration = new PeerNameRegistration();
        peerNameRegistration.PeerName = peerName;
        peerNameRegistration.Port = portNumber;
        peerNameRegistration.Comment = comment;
        peerNameRegistration.Cloud = cloudName;
        // Since the peerNameRegistration.EndPointCollection is not specified,
        // all (IPv4&IPv6) addresses assigned to the local host will
        // automatically be associated with the peerNameRegistration instance.
        // This behavior can be control using peerNameRegistration.UseAutoEndPointSelection

        //Note: Additional information may be specified on the PeerNameRegistration
        // object, which is not shown in this example.

        // Starting the registration means the name is published for
        // other peers to resolve
        peerNameRegistration.Start();
        Console.WriteLine("Registration of Peer Name: {0} complete.", peerName.ToString(), cloudName);
        Console.WriteLine();

        Console.WriteLine("Press any key to stop the registration and close the program");
        Console.ReadKey();

        // Stopping the registration means the name is no longer published
        peerNameRegistration.Stop();
    } catch(Exception e){
        Console.WriteLine("Error creating and registering the PeerName: {0} \n", e.Message);
        Console.WriteLine(e.StackTrace);
    }
}

설명

에 지정 된 피어 이름을 등록 합니다 PeerName 모든 소스 주소를 사용 하 여 속성 및 Port 생성자에 지정 합니다. 기본 포트는 엔드포인트이 지정 된 경우에이 메서드에서 사용 됩니다.

경우는 Cloud 속성은 null,이 메서드는에 지정 된 피어 이름을 등록를 PeerName 사용 하 여 속성을 Available 필드에 대 한 기본값을 초기화 하는 Name, Scope, 및 ScopeId.

후는 PeerNameRegistration 시작 된 다음 개체에는 Stop 메서드는 중지 하는 데 사용 됩니다.

등록을 업데이트 하는 Update 메서드를 사용 해야 합니다.

적용 대상