tangled
alpha
login
or
join now
moth11.net
/
lrcd
2
fork
atom
websocket-based lrcproto server
2
fork
atom
overview
issues
pulls
pipelines
export type on channel
moth11.net
3 months ago
e5f758b8
0bd0383e
+40
-48
2 changed files
expand all
collapse all
unified
split
options.go
server.go
+22
-24
options.go
···
8
8
lrcpb "github.com/rachel-mp4/lrcproto/gen/go"
9
9
)
10
10
11
11
+
type InitChanMsg struct {
12
12
+
lrcpb.Event_Init
13
13
+
*string
14
14
+
}
15
15
+
16
16
+
type MediaInitChanMsg struct {
17
17
+
lrcpb.Event_Mediainit
18
18
+
*string
19
19
+
}
20
20
+
11
21
type options struct {
12
12
-
uri string
13
13
-
secret string
14
14
-
welcome *string
15
15
-
writer *io.Writer
16
16
-
verbose bool
17
17
-
pubChan chan PubEvent
18
18
-
initChan chan struct {
19
19
-
lrcpb.Event_Init
20
20
-
*string
21
21
-
}
22
22
-
mediainitChan chan struct {
23
23
-
lrcpb.Event_Mediainit
24
24
-
*string
25
25
-
}
26
26
-
initialID *uint32
27
27
-
resolver func(externalID string, ctx context.Context) *string
22
22
+
uri string
23
23
+
secret string
24
24
+
welcome *string
25
25
+
writer *io.Writer
26
26
+
verbose bool
27
27
+
pubChan chan PubEvent
28
28
+
initChan chan InitChanMsg
29
29
+
mediainitChan chan MediaInitChanMsg
30
30
+
initialID *uint32
31
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
67
-
func WithInitChannel(initChan chan struct {
68
68
-
lrcpb.Event_Init
69
69
-
*string
70
70
-
}) Option {
71
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
80
-
func WithMediainitChannel(mediainitChan chan struct {
81
81
-
lrcpb.Event_Mediainit
82
82
-
*string
83
83
-
}) Option {
81
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
···
16
16
)
17
17
18
18
type Server struct {
19
19
-
secret string
20
20
-
uri string
21
21
-
eventBus chan clientEvent
22
22
-
ctx context.Context
23
23
-
cancel context.CancelFunc
24
24
-
clients map[*client]bool
25
25
-
clientsMu sync.Mutex
26
26
-
idmapsMu sync.Mutex
27
27
-
idToClient map[uint32]*client
28
28
-
lastID uint32
29
29
-
logger *log.Logger
30
30
-
debugLogger *log.Logger
31
31
-
welcomeEvt []byte
32
32
-
pongEvt []byte
33
33
-
initChan chan struct {
34
34
-
lrcpb.Event_Init
35
35
-
*string
36
36
-
}
37
37
-
mediainitChan chan struct {
38
38
-
lrcpb.Event_Mediainit
39
39
-
*string
40
40
-
}
41
41
-
resolver func(externalID string, ctx context.Context) *string
42
42
-
pubChan chan PubEvent
19
19
+
secret string
20
20
+
uri string
21
21
+
eventBus chan clientEvent
22
22
+
ctx context.Context
23
23
+
cancel context.CancelFunc
24
24
+
clients map[*client]bool
25
25
+
clientsMu sync.Mutex
26
26
+
idmapsMu sync.Mutex
27
27
+
idToClient map[uint32]*client
28
28
+
lastID uint32
29
29
+
logger *log.Logger
30
30
+
debugLogger *log.Logger
31
31
+
welcomeEvt []byte
32
32
+
pongEvt []byte
33
33
+
initChan chan InitChanMsg
34
34
+
mediainitChan chan MediaInitChanMsg
35
35
+
resolver func(externalID string, ctx context.Context) *string
36
36
+
pubChan chan PubEvent
43
37
}
44
38
45
39
type PubEvent struct {