package callscore import ( "sync" "amadan.net/oficina/calls/protocol" ) // The app this core is running in, as spec §15.28 has every app say on // its requests (protocol.ClientHeader): "mac 0.4.12". Set once by the // host before it joins; nothing is sent until it has been, which is how // an app from before §15.28 looks to the server, and the server calls // that "native". var client struct { sync.Mutex label string } // SetClient records the host app and its version. An app that is not // one protocol.ParseClient knows, or a version that is not digits and // dots, is refused and leaves nothing set. func SetClient(app, version string) bool { label := app + " " + version if parsed, _, ok := protocol.ParseClient(label); !ok || parsed == protocol.ClientNative { return false } client.Lock() client.label = label client.Unlock() return true } // ClientLabel is what SetClient recorded, or "". func ClientLabel() string { client.Lock() defer client.Unlock() return client.label } // RefreshICE asks the core for a fresh /ice answer now rather than at the // schedule's time (spec §15.28: a connection about to be restarted on // relay credentials that are due for renewal renews them first). The // answer arrives as the usual "ice" event; nothing happens before // admission, as for any fetch. func (r *Room) RefreshICE() { select { case r.iceWake <- struct{}{}: default: } }