🐛 Fix websocket connection when no auth provider panic

This commit is contained in:
LittleSheep 2024-10-11 19:37:20 +08:00
parent a6212335e7
commit fed972fc16

View File

@ -26,13 +26,16 @@ func ClientRegister(user models.Account, conn *websocket.Conn) uint64 {
wsConn[user.ID][clientId] = conn
wsMutex.Unlock()
pc, err := directory.GetServiceInstanceByType(hyper.ServiceTypeAuthProvider).GetGrpcConn()
srv := directory.GetServiceInstanceByType(hyper.ServiceTypeAuthProvider)
if srv != nil {
pc, err := srv.GetGrpcConn()
if err == nil {
proto.NewStreamControllerClient(pc).EmitStreamEvent(context.Background(), &proto.StreamEventRequest{
_, _ = proto.NewStreamControllerClient(pc).EmitStreamEvent(context.Background(), &proto.StreamEventRequest{
Event: "ClientRegister",
UserId: uint64(user.ID),
})
}
}
return clientId
}