Skip to content

Commit

Permalink
Merge pull request #67 from wolfendale/master
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniElectra authored Jun 25, 2024
2 parents 090cfb5 + 83e5157 commit 2b6ea02
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions prudp_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"net"
"runtime"
"time"

"github.com/PretendoNetwork/nex-go/v2/constants"
"github.com/lxzan/gws"
Expand Down Expand Up @@ -222,6 +223,14 @@ func (ps *PRUDPServer) Send(packet PacketInterface) {
}

ps.sendPacket(packet)

// * This delay is here to prevent the server from overloading the client with too many packets.
// * The 16ms (1/60th of a second) value is chosen based on testing with the friends server and is a good balance between
// * Not being too slow and also not dropping any packets because we've overloaded the client. This may be because it
// * roughly matches the framerate that most games target (60fps)
if i < fragments {
time.Sleep(16 * time.Millisecond)
}
}
}
}
Expand Down

0 comments on commit 2b6ea02

Please sign in to comment.