-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathannouncement.go
41 lines (31 loc) · 1.05 KB
/
announcement.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package moqtransport
import "github.com/mengelbart/moqtransport/internal/wire"
type Announcement struct {
responseCh chan trackNamespacer
namespace string
parameters wire.Parameters // TODO: This is unexported, need better API?
}
func (a *Announcement) Namespace() string {
return a.namespace
}
type AnnouncementResponseWriter interface {
Accept()
Reject(code uint64, reason string)
}
type AnnouncementHandler interface {
HandleAnnouncement(*Session, *Announcement, AnnouncementResponseWriter)
}
type AnnouncementHandlerFunc func(*Session, *Announcement, AnnouncementResponseWriter)
func (f AnnouncementHandlerFunc) HandleAnnouncement(s *Session, a *Announcement, arw AnnouncementResponseWriter) {
f(s, a, arw)
}
type defaultAnnouncementResponseWriter struct {
announcement *Announcement
session *Session
}
func (a *defaultAnnouncementResponseWriter) Accept() {
a.session.acceptAnnouncement(a.announcement)
}
func (a *defaultAnnouncementResponseWriter) Reject(code uint64, reason string) {
a.session.rejectAnnouncement(a.announcement, code, reason)
}