원격 디바이스 검색

앱에서 무선 네트워크, 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);

사용자 간 검색

개발자는 동일한 사용자에게 등록된 디바이스뿐만 아니라 클라이언트 디바이스에 근접한 모든 디바이스의 검색을 지정할 수 있습니다. 이는 특별 IRemoteSystemFilterRemoteSystemAuthorizationKindFilter를 통해 구현됩니다. 다른 필터 유형과 같이 구현됩니다.

// 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".
}

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

shared experiences settings page