Compare commits
2 Commits
ddb7ece622
...
32a2f822e0
Author | SHA1 | Date |
---|---|---|
Joachim Bauch | 32a2f822e0 | |
Joachim Bauch | ec62503bd3 |
|
@ -78,8 +78,8 @@ type CapabilitiesVersion struct {
|
|||
}
|
||||
|
||||
type CapabilitiesResponse struct {
|
||||
Version CapabilitiesVersion `json:"version"`
|
||||
Capabilities map[string]map[string]interface{} `json:"capabilities"`
|
||||
Version CapabilitiesVersion `json:"version"`
|
||||
Capabilities map[string]*json.RawMessage `json:"capabilities"`
|
||||
}
|
||||
|
||||
func (c *Capabilities) getCapabilities(key string) (map[string]interface{}, bool) {
|
||||
|
@ -174,12 +174,18 @@ func (c *Capabilities) loadCapabilities(ctx context.Context, u *url.URL) (map[st
|
|||
return nil, err
|
||||
}
|
||||
|
||||
capa, found := response.Capabilities[AppNameSpreed]
|
||||
if !found {
|
||||
capaObj, found := response.Capabilities[AppNameSpreed]
|
||||
if !found || capaObj == nil {
|
||||
log.Printf("No capabilities received for app spreed from %s: %+v", capUrl.String(), response)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
var capa map[string]interface{}
|
||||
if err := json.Unmarshal(*capaObj, &capa); err != nil {
|
||||
log.Printf("Unsupported capabilities received for app spreed from %s: %+v", capUrl.String(), response)
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
log.Printf("Received capabilities %+v from %s", capa, capUrl.String())
|
||||
c.setCapabilities(key, capa)
|
||||
return capa, nil
|
||||
|
|
|
@ -69,15 +69,18 @@ func NewCapabilitiesForTest(t *testing.T) (*url.URL, *Capabilities) {
|
|||
config := map[string]interface{}{
|
||||
"signaling": signaling,
|
||||
}
|
||||
spreedCapa, _ := json.Marshal(map[string]interface{}{
|
||||
"features": features,
|
||||
"config": config,
|
||||
})
|
||||
emptyArray := []byte("[]")
|
||||
response := &CapabilitiesResponse{
|
||||
Version: CapabilitiesVersion{
|
||||
Major: 20,
|
||||
},
|
||||
Capabilities: map[string]map[string]interface{}{
|
||||
"spreed": {
|
||||
"features": features,
|
||||
"config": config,
|
||||
},
|
||||
Capabilities: map[string]*json.RawMessage{
|
||||
"anotherApp": (*json.RawMessage)(&emptyArray),
|
||||
"spreed": (*json.RawMessage)(&spreedCapa),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
11
hub_test.go
11
hub_test.go
|
@ -420,15 +420,16 @@ func registerBackendHandlerUrl(t *testing.T, router *mux.Router, url string) {
|
|||
if strings.Contains(t.Name(), "MultiRoom") {
|
||||
signaling[ConfigKeySessionPingLimit] = 2
|
||||
}
|
||||
spreedCapa, _ := json.Marshal(map[string]interface{}{
|
||||
"features": features,
|
||||
"config": config,
|
||||
})
|
||||
response := &CapabilitiesResponse{
|
||||
Version: CapabilitiesVersion{
|
||||
Major: 20,
|
||||
},
|
||||
Capabilities: map[string]map[string]interface{}{
|
||||
"spreed": {
|
||||
"features": features,
|
||||
"config": config,
|
||||
},
|
||||
Capabilities: map[string]*json.RawMessage{
|
||||
"spreed": (*json.RawMessage)(&spreedCapa),
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue