/// <summary>
        /// Used to send SSDP packet
        /// </summary>
        /// <param name="data">The SSDP packet</param>
        /// <returns>unused</returns>
        public async Task<int> Send(string data)
        {

            var socket = new global::Windows.Networking.Sockets.DatagramSocket();
            {
                var profile = NetworkInformation.GetInternetConnectionProfile();

                
                socket.MessageReceived += (sender, args) =>
                {
                    var reader = new StreamReader(args.GetDataStream().AsStreamForRead());
                    {
                        string response = reader.ReadToEndAsync().Result;
                        OnMessageReceived(new MessageReceivedArgs(response));
                    }
                };

                socket.BindServiceNameAsync("", profile.NetworkAdapter);

                var remoteHost = new global::Windows.Networking.HostName(SSDP.Address);
                var reqBuff = Encoding.UTF8.GetBytes(data);

                var stream = await socket.GetOutputStreamAsync(remoteHost, SSDP.Port.ToString());
                await stream.WriteAsync(reqBuff.AsBuffer());

                if (socketJoined) return 0;

                socket.JoinMulticastGroup(remoteHost);
                socketJoined = !socketJoined;

                return 0;
            }
        }
Exemplo n.º 2
0
 public global::Windows.Foundation.IAsyncOperation <global::Windows.Networking.ServiceDiscovery.Dnssd.DnssdRegistrationResult> RegisterDatagramSocketAsync(global::Windows.Networking.Sockets.DatagramSocket socket, global::Windows.Networking.Connectivity.NetworkAdapter adapter)
 {
     throw new global::System.NotImplementedException("The member IAsyncOperation<DnssdRegistrationResult> DnssdServiceInstance.RegisterDatagramSocketAsync(DatagramSocket socket, NetworkAdapter adapter) is not implemented in Uno.");
 }
Exemplo n.º 3
0
 public global::Windows.Foundation.IAsyncAction AddDatagramSocketAsync(global::Windows.Networking.Sockets.DatagramSocket value)
 {
     throw new global::System.NotImplementedException("The member IAsyncAction WiFiDirectServiceSession.AddDatagramSocketAsync(DatagramSocket value) is not implemented in Uno.");
 }