Room creation time with ms resolution (#3362)
This commit is contained in:
+3
-1
@@ -279,7 +279,9 @@ func NewRoom(
|
||||
r.protoRoom.DepartureTimeout = roomConfig.DepartureTimeout
|
||||
}
|
||||
if r.protoRoom.CreationTime == 0 {
|
||||
r.protoRoom.CreationTime = time.Now().Unix()
|
||||
now := time.Now()
|
||||
r.protoRoom.CreationTime = now.Unix()
|
||||
r.protoRoom.CreationTimeMs = now.UnixMilli()
|
||||
}
|
||||
r.protoProxy = utils.NewProtoProxy[*livekit.Room](roomUpdateInterval, r.updateProto)
|
||||
|
||||
|
||||
@@ -53,7 +53,9 @@ func NewLocalStore() *LocalStore {
|
||||
|
||||
func (s *LocalStore) StoreRoom(_ context.Context, room *livekit.Room, internal *livekit.RoomInternal) error {
|
||||
if room.CreationTime == 0 {
|
||||
room.CreationTime = time.Now().Unix()
|
||||
now := time.Now()
|
||||
room.CreationTime = now.Unix()
|
||||
room.CreationTimeMs = now.UnixMilli()
|
||||
}
|
||||
roomName := livekit.RoomName(room.Name)
|
||||
|
||||
|
||||
@@ -123,7 +123,9 @@ func (s *RedisStore) Stop() {
|
||||
|
||||
func (s *RedisStore) StoreRoom(_ context.Context, room *livekit.Room, internal *livekit.RoomInternal) error {
|
||||
if room.CreationTime == 0 {
|
||||
room.CreationTime = time.Now().Unix()
|
||||
now := time.Now()
|
||||
room.CreationTime = now.Unix()
|
||||
room.CreationTimeMs = now.UnixMilli()
|
||||
}
|
||||
|
||||
roomData, err := proto.Marshal(room)
|
||||
|
||||
@@ -71,11 +71,13 @@ func (r *StandardRoomAllocator) CreateRoom(ctx context.Context, req *livekit.Cre
|
||||
rm, internal, err := r.roomStore.LoadRoom(ctx, livekit.RoomName(req.Name), true)
|
||||
if errors.Is(err, ErrRoomNotFound) {
|
||||
created = true
|
||||
now := time.Now()
|
||||
rm = &livekit.Room{
|
||||
Sid: guid.New(utils.RoomPrefix),
|
||||
Name: req.Name,
|
||||
CreationTime: time.Now().Unix(),
|
||||
TurnPassword: utils.RandomSecret(),
|
||||
Sid: guid.New(utils.RoomPrefix),
|
||||
Name: req.Name,
|
||||
CreationTime: now.Unix(),
|
||||
CreationTimeMs: now.UnixMilli(),
|
||||
TurnPassword: utils.RandomSecret(),
|
||||
}
|
||||
internal = &livekit.RoomInternal{}
|
||||
applyDefaultRoomConfig(rm, internal, &r.config.Room)
|
||||
|
||||
Reference in New Issue
Block a user