test relay server
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 2m1s
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 2m1s
This commit is contained in:
31
internal/relay/relay.go
Normal file
31
internal/relay/relay.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package relay
|
||||
|
||||
import (
|
||||
"sync"
|
||||
|
||||
"github.com/okdaichi/gomoqt/moqt"
|
||||
)
|
||||
|
||||
type Relay struct {
|
||||
mu sync.RWMutex
|
||||
rooms map[string]*moqt.TrackMux
|
||||
}
|
||||
|
||||
func New() *Relay {
|
||||
return &Relay{
|
||||
rooms: make(map[string]*moqt.TrackMux),
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Relay) GetMux(room string) *moqt.TrackMux {
|
||||
r.mu.Lock()
|
||||
defer r.mu.Unlock()
|
||||
|
||||
if mux, ok := r.rooms[room]; ok {
|
||||
return mux
|
||||
}
|
||||
|
||||
mux := moqt.NewTrackMux()
|
||||
r.rooms[room] = mux
|
||||
return mux
|
||||
}
|
||||
Reference in New Issue
Block a user