다음을 통해 공유


원격 디바이스 검색

앱은 무선 네트워크, Bluetooth 및 클라우드 연결을 사용하여 검색 디바이스와 동일한 Microsoft 계정으로 로그온된 Windows 디바이스를 검색할 수 있습니다. 원격 디바이스는 검색하기 위해 특별한 소프트웨어를 설치할 필요가 없습니다.

비고

이 가이드에서는 원격 앱시작의 단계를 따라 원격 시스템 기능에 대한 액세스 권한이 이미 부여된 것으로 가정합니다.

검색 가능한 디바이스 집합 필터링

필터를 사용하여 RemoteSystemWatcher를 통해 검색 가능한 디바이스 집합의 범위를 좁힐 수 있습니다. 필터는 검색 유형(프록시 및 로컬 네트워크 및 클라우드 연결), 디바이스 유형(데스크톱, 모바일 장치, Xbox, 허브 및 홀로그램) 및 가용성 상태(원격 시스템 기능을 사용하는 디바이스의 가용성 상태)를 검색할 수 있습니다.

필터 개체는 생성자에 매개 변수로 전달되므로 RemoteSystemWatcher 개체가 초기화되기 전이나 초기화되는 동안 생성되어야 합니다. 다음 코드는 사용 가능한 각 형식의 필터를 만든 다음 목록에 추가합니다.

비고

이러한 예제의 코드는 파일에 using Windows.System.RemoteSystems 구문이 있어야 합니다.

private List<IRemoteSystemFilter> makeFilterList()
{
    // construct an empty list
    List<IRemoteSystemFilter> localListOfFilters = new List<IRemoteSystemFilter>();

    // construct a discovery type filter that only allows "proximal" connections:
    RemoteSystemDiscoveryTypeFilter discoveryFilter = new RemoteSystemDiscoveryTypeFilter(RemoteSystemDiscoveryType.Proximal);


    // construct a device type filter that only allows desktop and mobile devices:
    // For this kind of filter, we must first create an IIterable of strings representing the device types to allow.
    // These strings are stored as static read-only properties of the RemoteSystemKinds class.
    List<String> listOfTypes = new List<String>();
    listOfTypes.Add(RemoteSystemKinds.Desktop);
    listOfTypes.Add(RemoteSystemKinds.Phone);

    // Put the list of device types into the constructor of the filter
    RemoteSystemKindFilter kindFilter = new RemoteSystemKindFilter(listOfTypes);


    // construct an availibility status filter that only allows devices marked as available:
    RemoteSystemStatusTypeFilter statusFilter = new RemoteSystemStatusTypeFilter(RemoteSystemStatusType.Available);


    // add the 3 filters to the listL
    localListOfFilters.Add(discoveryFilter);
    localListOfFilters.Add(kindFilter);
    localListOfFilters.Add(statusFilter);

    // return the list
    return localListOfFilters;
}

비고

"근접" 필터 값은 물리적 근접도를 보장하지 않습니다. 신뢰할 수 있는 물리적 근접성이 필요한 시나리오의 경우 필터에서 RemoteSystemDiscoveryType.SpatiallyProximal 값을 사용합니다. 현재 이 필터는 Bluetooth에서 검색된 디바이스만 허용합니다. 물리적 근접성을 보장하는 새로운 검색 메커니즘 및 프로토콜이 지원되므로 여기에도 포함됩니다.
또한 RemoteSystem 클래스에는 검색된 디바이스가 실제로 물리적 근접성(RemoteSystem.IsAvailableBySpatialProximity) 내에 있는지 여부를 나타내는 속성이 있습니다.

비고

로컬 네트워크를 통해 디바이스를 검색하려는 경우(검색 유형 필터 선택에 따라 결정됨) 네트워크는 "프라이빗" 또는 "도메인" 프로필을 사용해야 합니다. 디바이스는 "공용" 네트워크를 통해 다른 디바이스를 검색하지 않습니다.

IRemoteSystemFilter 개체 목록이 만들어지면 이를 RemoteSystemWatcher생성자에 전달할 수 있습니다.

// store filter list
List<IRemoteSystemFilter> listOfFilters = makeFilterList();

// construct watcher with the list
m_remoteSystemWatcher = RemoteSystem.CreateWatcher(listOfFilters);

이 감시자의 Start 메서드가 호출되면 다음 조건을 모두 충족하는 디바이스가 검색 된 경우에만 RemoteSystemAdded 이벤트가 발생합니다.

  • 근접 연결을 통해 발견할 수 있습니다.
  • 데스크톱 또는 휴대폰입니다.
  • 사용 가능한 것으로 분류됩니다.

여기에서 이벤트를 처리하고, RemoteSystem 개체를 검색하고, 원격 디바이스에 연결하는 절차는 원격 앱시작과 동일합니다. 즉, RemoteSystem 개체는 각 RemoteSystemAdded 이벤트와 함께 전달되는 RemoteSystemAddedEventArgs 개체의 속성으로 저장됩니다.

주소 입력으로 디바이스 검색

일부 디바이스는 사용자와 연결되지 않거나 검색을 통해 검색할 수 없지만 검색 앱에서 직접 주소를 사용하는 경우에도 연결할 수 있습니다. HostName 클래스는 원격 디바이스의 주소를 나타내는 데 사용됩니다. IP 주소 형식으로 저장되는 경우가 많지만 다른 여러 형식이 허용됩니다(자세한 내용은 HostName 생성자 참조).

유효한 HostName 개체가 제공되면 RemoteSystem 개체가 검색됩니다. 주소 데이터가 잘못되면 개체 참조가 null 반환됩니다.

private async Task<RemoteSystem> getDeviceByAddressAsync(string IPaddress)
{
    // construct a HostName object
    Windows.Networking.HostName deviceHost = new Windows.Networking.HostName(IPaddress);

    // create a RemoteSystem object with the HostName
    RemoteSystem remotesys = await RemoteSystem.FindByHostNameAsync(deviceHost);

    return remotesys;
}

원격 시스템에서 기능 쿼리

검색 필터링과는 별개이지만 디바이스 기능 쿼리는 검색 프로세스의 중요한 부분이 될 수 있습니다. RemoteSystem.GetCapabilitySupportedAsync 메서드를 사용하여 검색된 원격 시스템을 쿼리하여 원격 세션 연결 또는 공간 엔터티(홀로그램) 공유와 같은 특정 기능을 지원할 수 있습니다. 쿼리 가능한 기능 목록은 KnownRemoteSystemCapabilities 클래스를 참조하세요.

// Check to see if the given remote system can accept LaunchUri requests
bool isRemoteSystemLaunchUriCapable = remoteSystem.GetCapabilitySupportedAsync(KnownRemoteSystemCapabilities.LaunchUri);

사용자 간 검색

개발자는 클라이언트 디바이스에 근접한 모든 디바이스의 검색을 지정할 수 있으며, 이는 동일한 사용자에게 등록된 디바이스에만 국한되지 않습니다. 이는 IRemoteSystemFilter와 같이 RemoteSystemAuthorizationKindFilter을 통해 특수하게 구현됩니다. 다른 필터 형식과 같이 구현됩니다.

// Construct a user type filter that includes anonymous devices
RemoteSystemAuthorizationKindFilter authorizationKindFilter = new RemoteSystemAuthorizationKindFilter(RemoteSystemAuthorizationKind.Anonymous);
// then add this filter to the RemoteSystemWatcher
  • RemoteSystemAuthorizationKind 값이 Anonymous인 경우, 모든 근접 디바이스를 발견할 수 있도록 허용하며, 여기에는 신뢰할 수 없는 사용자의 디바이스도 포함됩니다.
  • SameUser 값은 클라이언트 디바이스와 동일한 사용자에게 등록된 디바이스로만 검색을 필터링합니다. 이 옵션은 기본 동작입니다.

사용자 간 공유 설정 확인

검색 앱에 지정된 위의 필터 외에도 다른 사용자와 로그인한 디바이스의 공유 환경을 허용하도록 클라이언트 디바이스 자체를 구성해야 합니다. RemoteSystem 클래스의 정적 메서드를 사용하여 쿼리할 수 있는 시스템 설정입니다.

if (!RemoteSystem.IsAuthorizationKindEnabled(RemoteSystemAuthorizationKind.Anonymous)) {
	// The system is not authorized to connect to cross-user devices. 
	// Inform the user that they can discover more devices if they
	// update the setting to "Anonymous".
}

이 설정을 변경하려면 사용자가 설정을 열어야 합니다. 시스템>공유 환경>디바이스 간 공유 메뉴에는 사용자가 시스템에서 공유할 수 있는 디바이스를 지정할 수 있는 드롭다운 상자가 있습니다.

공유 환경 설정 페이지