All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 2m1s
32 lines
433 B
Go
32 lines
433 B
Go
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
|
|
}
|