-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_test.go
More file actions
42 lines (35 loc) · 852 Bytes
/
example_test.go
File metadata and controls
42 lines (35 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package jango_test
import (
"context"
"fmt"
"github.com/dinalt/jango"
"github.com/dinalt/jango/transport"
"github.com/dinalt/jango/videoroom"
)
func Example() {
admin := jango.Admin{
AdminSecret: "janusoverlord",
Transport: &transport.HTTP{
URL: "http://localhost:7088/admin",
},
}
ctx := context.Background()
// Ping Janus server
if err := admin.PingCtx(ctx); err != nil {
panic(err)
}
// Get sessions list
sessions, err := admin.SessionsCtx(ctx)
if err != nil {
panic(err)
}
fmt.Printf("sessions count: %d\n", len(sessions))
// Plugin request
req := videoroom.ListRequest{}
res := videoroom.ListResponse{}
if err := admin.PluginRequestCtx(ctx, &req, &res); err != nil {
panic(err)
}
// We don't need to check res.Err() here, PluginRequestCtx do it for us.
fmt.Printf("rooms count: %d\n", len(res.List))
}