Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
aymericbeaumet committed Nov 2, 2023
1 parent 69ea6e6 commit 897d1ab
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ios/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,13 @@ func (app *App) PostMessages(w http.ResponseWriter, r *http.Request) {
chat.messages = append(chat.messages, newMessage)
app.publishEvent("messages", newMessage)
app.idempotencyKeys[idempotencyKey] = struct{}{}
go app.delayAnswer(chat)
go app.sendDelayedAnswer(chat)

w.WriteHeader(http.StatusOK)
render.JSON(w, r, newMessage)
}

func (app *App) delayAnswer(chat *Chat) {
func (app *App) sendDelayedAnswer(chat *Chat) {
<-time.After(3*time.Second + time.Duration(rand.Intn(3))*time.Second)

app.mu.Lock()
Expand Down

0 comments on commit 897d1ab

Please sign in to comment.