dkforest

A forum and chat platform (onion)
git clone https://git.dasho.dev/n0tr1v/dkforest.git
Log | Files | Refs | LICENSE

stream.go (628B)


      1 package stream
      2 
      3 import (
      4 	"dkforest/pkg/database"
      5 	"dkforest/pkg/web/handlers/usersStreamsManager"
      6 	hutils "dkforest/pkg/web/handlers/utils"
      7 	"github.com/labstack/echo"
      8 )
      9 
     10 type Item struct {
     11 	Quit <-chan struct{}
     12 	item *usersStreamsManager.Item
     13 }
     14 
     15 func (s *Item) Cleanup() {
     16 	s.item.Cleanup()
     17 }
     18 
     19 func SetStreaming(c echo.Context, userID database.UserID, key string) (*Item, error) {
     20 	// Keep track of users streams, so we can limit how many are open at one time per user
     21 	item, err := usersStreamsManager.Inst.Add(userID, key)
     22 	if err != nil {
     23 		return nil, err
     24 	}
     25 	return &Item{Quit: hutils.SetStreaming(c), item: item}, nil
     26 }