server-sdk-go
server-sdk-go copied to clipboard
Room does not get closed
Hi there!
So I'm trying to close a room. I got a participant (client
) using the server-sdk-go
and another program called closer
which tries to close the room.
client
package main
import (
"fmt"
"github.com/livekit/protocol/livekit"
lksdk "github.com/livekit/server-sdk-go"
"github.com/thanhpk/randstr"
)
func main() {
host := "ws://localhost:7880"
apiKey := "devkey"
apiSecret := "secret"
roomName := "myroom"
identity := randstr.Hex(16)
close := make(chan bool)
roomCB := &lksdk.RoomCallback{
ParticipantCallback: lksdk.ParticipantCallback{},
OnReconnecting: func() {
fmt.Print("OnReconnecting")
},
OnReconnected: func() {
fmt.Print("OnReconnected")
},
OnDisconnected: func() {
fmt.Print("OnDisconnected")
close <- true
},
}
room, err := lksdk.ConnectToRoom(host, lksdk.ConnectInfo{
APIKey: apiKey,
APISecret: apiSecret,
RoomName: roomName,
ParticipantIdentity: identity,
}, roomCB)
if err != nil {
panic(err)
}
<-close
room.Disconnect()
}
closer
package main
import (
"context"
"fmt"
livekit "github.com/livekit/protocol/livekit"
lksdk "github.com/livekit/server-sdk-go"
)
func main() {
host := "ws://localhost:7880"
apiKey := "devkey"
apiSecret := "secret"
roomClient := lksdk.NewRoomServiceClient(host, apiKey, apiSecret)
res_list, _ := roomClient.ListRooms(context.Background(), &livekit.ListRoomsRequest{})
roomId := res_list.GetRooms()[0].GetSid()
fmt.Printf("sid: '%s'\n", roomId)
res_delete, err := roomClient.DeleteRoom(context.Background(), &livekit.DeleteRoomRequest{
Room: roomId,
})
fmt.Printf("res_delete: '%s', error: %v\n", res_delete.String(), err)
fmt.Printf("done\n")
}
issue
So there is no error, however the room does not get closed either. Simply nothing happens. Btw when I use an invalid roomId
I get no error either.
the server logs DEBUG livekit service/roommanager.go:453 Deleting non-rtc room, loading from roomstore
I expected that the client will get disconnected and that the signal OnDisconnected
would get called.
versions
-
github.com/livekit/server-sdk-go v0.10.4
-
docker run --rm -it --network host livekit/livekit-server:v1.1.2 --dev
Thanks for your time!