+22
-24
options.go
+22
-24
options.go
···
8
8
lrcpb "github.com/rachel-mp4/lrcproto/gen/go"
9
9
)
10
10
11
+
type InitChanMsg struct {
12
+
lrcpb.Event_Init
13
+
*string
14
+
}
15
+
16
+
type MediaInitChanMsg struct {
17
+
lrcpb.Event_Mediainit
18
+
*string
19
+
}
20
+
11
21
type options struct {
12
-
uri string
13
-
secret string
14
-
welcome *string
15
-
writer *io.Writer
16
-
verbose bool
17
-
pubChan chan PubEvent
18
-
initChan chan struct {
19
-
lrcpb.Event_Init
20
-
*string
21
-
}
22
-
mediainitChan chan struct {
23
-
lrcpb.Event_Mediainit
24
-
*string
25
-
}
26
-
initialID *uint32
27
-
resolver func(externalID string, ctx context.Context) *string
22
+
uri string
23
+
secret string
24
+
welcome *string
25
+
writer *io.Writer
26
+
verbose bool
27
+
pubChan chan PubEvent
28
+
initChan chan InitChanMsg
29
+
mediainitChan chan MediaInitChanMsg
30
+
initialID *uint32
31
+
resolver func(externalID string, ctx context.Context) *string
28
32
}
29
33
30
34
type Option func(option *options) error
···
64
68
}
65
69
}
66
70
67
-
func WithInitChannel(initChan chan struct {
68
-
lrcpb.Event_Init
69
-
*string
70
-
}) Option {
71
+
func WithInitChannel(initChan chan InitChanMsg) Option {
71
72
return func(options *options) error {
72
73
if initChan == nil {
73
74
return errors.New("must provide a channel")
···
77
78
}
78
79
}
79
80
80
-
func WithMediainitChannel(mediainitChan chan struct {
81
-
lrcpb.Event_Mediainit
82
-
*string
83
-
}) Option {
81
+
func WithMediainitChannel(mediainitChan chan MediaInitChanMsg) Option {
84
82
return func(options *options) error {
85
83
if mediainitChan == nil {
86
84
return errors.New("must provide a channel")
+18
-24
server.go
+18
-24
server.go
···
16
16
)
17
17
18
18
type Server struct {
19
-
secret string
20
-
uri string
21
-
eventBus chan clientEvent
22
-
ctx context.Context
23
-
cancel context.CancelFunc
24
-
clients map[*client]bool
25
-
clientsMu sync.Mutex
26
-
idmapsMu sync.Mutex
27
-
idToClient map[uint32]*client
28
-
lastID uint32
29
-
logger *log.Logger
30
-
debugLogger *log.Logger
31
-
welcomeEvt []byte
32
-
pongEvt []byte
33
-
initChan chan struct {
34
-
lrcpb.Event_Init
35
-
*string
36
-
}
37
-
mediainitChan chan struct {
38
-
lrcpb.Event_Mediainit
39
-
*string
40
-
}
41
-
resolver func(externalID string, ctx context.Context) *string
42
-
pubChan chan PubEvent
19
+
secret string
20
+
uri string
21
+
eventBus chan clientEvent
22
+
ctx context.Context
23
+
cancel context.CancelFunc
24
+
clients map[*client]bool
25
+
clientsMu sync.Mutex
26
+
idmapsMu sync.Mutex
27
+
idToClient map[uint32]*client
28
+
lastID uint32
29
+
logger *log.Logger
30
+
debugLogger *log.Logger
31
+
welcomeEvt []byte
32
+
pongEvt []byte
33
+
initChan chan InitChanMsg
34
+
mediainitChan chan MediaInitChanMsg
35
+
resolver func(externalID string, ctx context.Context) *string
36
+
pubChan chan PubEvent
43
37
}
44
38
45
39
type PubEvent struct {