From cc178b1ebdc27339ec4b53b609ce8764b84d94b1 Mon Sep 17 00:00:00 2001 From: benyamin Date: Thu, 24 Aug 2023 18:01:10 +0330 Subject: [PATCH] feat: retry add ice 3 times --- controllers/room.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/controllers/room.go b/controllers/room.go index 1fb5757..6eb2d1b 100644 --- a/controllers/room.go +++ b/controllers/room.go @@ -53,7 +53,17 @@ func (c *RoomController) AddICECandidate(ctx *gin.Context) { c.helper.ResponseUnprocessableEntity(ctx) return } + tryCounter := 0 +start: err := c.repo.AddPeerIceCandidate(reqModel.RoomId, reqModel.ID, reqModel.ICECandidate) + if err != nil { + if tryCounter < 4 { + time.Sleep(1 * time.Second) + tryCounter++ + goto start + } + } + if c.helper.HandleIfErr(ctx, err, nil) { return }