backend for xcvr appview

make signets for mediainits

+25 -6
+25 -6
server/internal/model/channel.go
··· 31 31 logger *log.Logger 32 32 valid bool 33 33 34 - welcome string 35 - server *lrcd.Server 36 - lastID uint32 37 - initChan <-chan lrcpb.Event_Init 38 - ctx context.Context 39 - cancel func() 34 + welcome string 35 + server *lrcd.Server 36 + lastID uint32 37 + initChan <-chan lrcpb.Event_Init 38 + mediainitChan <-chan lrcpb.Event_Mediainit 39 + ctx context.Context 40 + cancel func() 40 41 41 42 clients map[*client]bool 42 43 clientsmu sync.Mutex ··· 164 165 var err error 165 166 lastID := cm.lastID 166 167 initChan := make(chan lrcpb.Event_Init, 100) 168 + mediainitChan := make(chan lrcpb.Event_Mediainit, 100) 167 169 168 170 server, err := lrcd.NewServer( 169 171 lrcd.WithWelcome(cm.welcome), 170 172 lrcd.WithLogging(os.Stdout, true), 171 173 lrcd.WithInitialID(lastID), 172 174 lrcd.WithInitChannel(initChan), 175 + lrcd.WithMediainitChannel(mediainitChan), 173 176 lrcd.WithServerURIAndSecret(uri, os.Getenv("LRCD_SECRET")), 174 177 ) 175 178 if err != nil { ··· 189 192 ctx, cancel := context.WithCancel(context.Background()) 190 193 cm.server = server 191 194 cm.initChan = initChan 195 + cm.mediainitChan = mediainitChan 192 196 cm.cancel = cancel 193 197 cm.ctx = ctx 194 198 ··· 225 229 if !ok { 226 230 cm.logger.Println("this is a weird case!") 227 231 return 232 + } 233 + err := m.rm.PostSignet(e, cm.uri, context.Background()) 234 + if err != nil { 235 + m.logger.Println("error posting signet: " + err.Error()) 236 + } 237 + case me, ok := <-cm.mediainitChan: 238 + if !ok { 239 + cm.logger.Println("this is a weird case!") 240 + return 241 + } 242 + e := lrcpb.Event_Init{ 243 + Init: &lrcpb.Init{ 244 + Id: me.Mediainit.Id, 245 + ExternalID: me.Mediainit.ExternalID, 246 + }, 228 247 } 229 248 err := m.rm.PostSignet(e, cm.uri, context.Background()) 230 249 if err != nil {