Inheritance: IMediaServer, IPrefixHandler
Esempio n. 1
0
        public void RegisterMediaServer(IMediaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }
            var guid = server.UUID;

            if (servers.ContainsKey(guid))
            {
                throw new ArgumentException("Attempting to register more than once");
            }

            var end   = (IPEndPoint)listener.LocalEndpoint;
            var mount = new MediaMount(server);

            servers[guid] = mount;
            RegisterHandler(mount);

            foreach (var address in IP.ExternalIPAddresses)
            {
                DebugFormat("Registering device for {0}", address);
                var deviceGuid = Guid.NewGuid();
                var list       = devicesForServers.GetOrAdd(guid, new List <Guid>());
                lock (list) {
                    list.Add(deviceGuid);
                }
                mount.AddDeviceGuid(deviceGuid, address);
                var uri = new Uri($"http://{address}:{end.Port}{mount.DescriptorURI}");
                lock (list) {
                    ssdpServer.RegisterNotification(deviceGuid, uri, address);
                }
                NoticeFormat("New mount at: {0}", uri);
            }
        }
Esempio n. 2
0
        public void RegisterMediaServer(IMediaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            var guid = server.Uuid;

            if (servers.ContainsKey(guid))
            {
                throw new ArgumentException("Attempting to register more than once");
            }

            var end   = listener.LocalEndpoint as IPEndPoint;
            var mount = new MediaMount(server);

            servers[guid] = mount;
            RegisterHandler(mount);

            foreach (var address in IP.ExternalIPAddresses)
            {
                var uri = new Uri(string.Format("http://{0}:{1}{2}", address, end.Port, mount.DescriptorURI));
                ssdpServer.RegisterNotification(guid, uri);
                InfoFormat("New mount at: {0}", uri);
            }
        }
Esempio n. 3
0
        public void RegisterMediaServer(IMediaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException(nameof(server));
            }
            var guid = server.UUID;

            if (servers.ContainsKey(guid))
            {
                throw new ArgumentException("Attempting to register more than once");
            }

            var end   = (IPEndPoint)listener.LocalEndpoint;
            var mount = new MediaMount(server);

            servers[guid] = mount;
            RegisterHandler(mount);

            foreach (var address in IP.ExternalIPAddresses)
            {
                DebugFormat("Registering device for {0}", address);

                // Setup initial byes based on server and machine
                var macBytes    = HexadecimalStringToByteArray(IP.GetMAC(address).Replace(":", ""));
                var addressByte = address.GetAddressBytes()[0];
                var serverBytes = MD5Hash(server.FriendlyName);
                var guidBytes   = macBytes.Concat(new byte[] { addressByte }).Concat(serverBytes.Take(16 - 1 - macBytes.Length)).ToArray();

                var lguid      = new Guid(guidBytes);
                var deviceGuid = lguid;
                var list       = devicesForServers.GetOrAdd(guid, new List <Guid>());
                lock (list) {
                    list.Add(deviceGuid);
                }
                mount.AddDeviceGuid(deviceGuid, address);
                var uri = new Uri($"http://{address}:{end.Port}{mount.DescriptorURI}");
                lock (list) {
                    ssdpServer.RegisterNotification(deviceGuid, uri, address);
                }
                NoticeFormat("New mount at: {0}", uri);
            }
        }
Esempio n. 4
0
        public void RegisterMediaServer(IMediaServer server)
        {
            if (server == null)
            {
                throw new ArgumentNullException("server");
            }
            var guid = server.Uuid;

            if (servers.ContainsKey(guid))
            {
                throw new ArgumentException("Attempting to register more than once");
            }

            var end   = listener.LocalEndpoint as IPEndPoint;
            var mount = new MediaMount(server);

            servers[guid] = mount;
            RegisterHandler(mount);

            foreach (var address in IP.ExternalIPAddresses)
            {
                DebugFormat("Registering device for {0}", address);
                var lguid =
                    new Guid(System.Text.Encoding.UTF8.GetBytes(IP.GetMAC(address).Replace(":", "") + "." + (address.Address % 256).ToString()));
                var deviceGuid = lguid;
                var list       = devicesForServers.GetOrAdd(guid, new List <Guid>());
                lock (list) {
                    list.Add(deviceGuid);
                }
                mount.AddDeviceGuid(deviceGuid, address);
                var uri = new Uri(string.Format(
                                      "http://{0}:{1}{2}",
                                      address,
                                      end.Port,
                                      mount.DescriptorURI
                                      ));
                ssdpServer.RegisterNotification(deviceGuid, uri, address);
                NoticeFormat("New mount at: {0}", uri);
            }
        }
Esempio n. 5
0
    public void RegisterMediaServer(IMediaServer server)
    {
      if (server == null) {
        throw new ArgumentNullException("server");
      }
      var guid = server.Uuid;
      if (servers.ContainsKey(guid)) {
        throw new ArgumentException("Attempting to register more than once");
      }

      var end = listener.LocalEndpoint as IPEndPoint;
      var mount = new MediaMount(server);
      servers[guid] = mount;
      RegisterHandler(mount);

      foreach (var address in IP.ExternalIPAddresses) {
        DebugFormat("Registering device for {0}", address);
        var deviceGuid = Guid.NewGuid();
        var list = devicesForServers.GetOrAdd(guid, new List<Guid>());
        lock (list) {
          list.Add(deviceGuid);
        }
        mount.AddDeviceGuid(deviceGuid, address);
        var uri = new Uri(string.Format(
          "http://{0}:{1}{2}",
          address,
          end.Port,
          mount.DescriptorURI
          ));
        ssdpServer.RegisterNotification(deviceGuid, uri, address);
        NoticeFormat("New mount at: {0}", uri);
      }
    }
Esempio n. 6
0
        public void RegisterMediaServer(IMediaServer server)
        {
            if (server == null) {
            throw new ArgumentNullException("server");
              }
              var guid = server.Uuid;
              if (servers.ContainsKey(guid)) {
            throw new ArgumentException("Attempting to register more than once");
              }

              var end = listener.LocalEndpoint as IPEndPoint;
              var mount = new MediaMount(server);
              servers[guid] = mount;
              RegisterHandler(mount);

              foreach (var address in IP.ExternalIPAddresses) {
            var uri = new Uri(string.Format("http://{0}:{1}{2}", address, end.Port, mount.DescriptorURI));
            ssdpServer.RegisterNotification(guid, uri);
            NoticeFormat("New mount at: {0}", uri);
              }
        }