MCPcopy Index your code
hub / github.com/Threadfin/Threadfin / SSDP

Function SSDP

src/ssdp.go:14–72  ·  view source on GitHub ↗

SSDP : SSPD / DLNA Server

()

Source from the content-addressed store, hash-verified

12
13// SSDP : SSPD / DLNA Server
14func SSDP() (err error) {
15
16 if Settings.SSDP == false || System.Flag.Info == true {
17 return
18 }
19
20 showInfo(fmt.Sprintf("SSDP / DLNA:%t", Settings.SSDP))
21
22 quit := make(chan os.Signal, 1)
23 signal.Notify(quit, os.Interrupt)
24
25 ad, err := ssdp.Advertise(
26 fmt.Sprintf("upnp:rootdevice"), // send as "ST"
27 fmt.Sprintf("uuid:%s::upnp:rootdevice", System.DeviceID), // send as "USN"
28 fmt.Sprintf("%s/device.xml", System.URLBase), // send as "LOCATION"
29 System.AppName, // send as "SERVER"
30 1800) // send as "maxAge" in "CACHE-CONTROL"
31
32 if err != nil {
33 return
34 }
35
36 // Debug SSDP
37 if System.Flag.Debug == 3 {
38 ssdp.Logger = log.New(os.Stderr, "[SSDP] ", log.LstdFlags)
39 }
40
41 go func(adv *ssdp.Advertiser) {
42
43 aliveTick := time.Tick(300 * time.Second)
44
45 loop:
46 for {
47
48 select {
49
50 case <-aliveTick:
51 err = adv.Alive()
52 if err != nil {
53 ShowError(err, 0)
54 adv.Bye()
55 adv.Close()
56 break loop
57 }
58
59 case <-quit:
60 adv.Bye()
61 adv.Close()
62 os.Exit(0)
63 break loop
64
65 }
66
67 }
68
69 }(ad)
70
71 return

Callers 1

InitFunction · 0.85

Calls 2

showInfoFunction · 0.85
ShowErrorFunction · 0.85

Tested by

no test coverage detected