/// <summary> /// Unregisters and removes the DNS-SD service. If this method is not called, /// the registration will remain discoverable, even if the app is not running. /// </summary> public override bool StopAdvertising() { if (_socket != null && _service != null) { _socket.ConnectionReceived -= MessageToConnectReceivedFromParticipantAsync; _socket.Dispose(); _socket = null; _service = null; return(true); } return(false); }
/// <summary> /// Registers the DNS-SD service. /// </summary> public override async Task <bool> StartAdvertisingAsync() { if (_socket == null && _service == null) { _socket = new StreamSocketListener(); _socket.ConnectionReceived += MessageToConnectReceivedFromParticipantAsync; await _socket.BindServiceNameAsync(Port); _service = new DnssdServiceInstance( $"{InstanceName}.{SERVICE_TYPE}.{NETWORK_PROTOCOL}.{DOMAIN}.", NetworkInformation.GetHostNames().FirstOrDefault(x => x.Type == HostNameType.DomainName && x.RawName.Contains("local")), UInt16.Parse(_socket.Information.LocalPort) ); var operationStatus = await _service.RegisterStreamSocketListenerAsync(_socket); return(true); } return(false); }
/// <summary> /// Registers the DNS-SD service. /// </summary> public override async Task<bool> StartAdvertisingAsync() { bool status = false; if (_socket == null && _service == null) { _socket = new StreamSocketListener(); _socket.ConnectionReceived += MessageToConnectReceivedFromParticipantAsync; await _socket.BindServiceNameAsync(Port); _service = new DnssdServiceInstance( $"{InstanceName}.{SERVICE_TYPE}.{NETWORK_PROTOCOL}.{DOMAIN}.", NetworkInformation.GetHostNames() .FirstOrDefault(x => x.Type == HostNameType.DomainName && x.RawName.Contains("local")), UInt16.Parse(_socket.Information.LocalPort) ); var operationStatus = await _service.RegisterStreamSocketListenerAsync(_socket); status = true; } return status; }
/// <summary> /// Unregisters and removes the DNS-SD service. If this method is not called, /// the registration will remain discoverable, even if the app is not running. /// </summary> public override bool StopAdvertising() { bool status = false; if (_socket != null && _service != null) { _socket.ConnectionReceived -= MessageToConnectReceivedFromParticipantAsync; _socket.Dispose(); _socket = null; _service = null; status = true; } return status; }