Merge pull request #17 from nnnnt21/rtt

This commit is contained in:
Melissa 2025-07-27 15:22:16 +02:00 committed by GitHub
commit 114595382d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

33
peer.go
View file

@ -40,6 +40,14 @@ type Peer interface {
//
// http://enet.bespin.org/structENetPeer.html#a1873959810db7ac7a02da90469ee384e
GetData() []byte
//rtt
GetRoundTripTime() uint32
GetLastRoundTripTime() uint32
GetLowestRoundTripTime() uint32
GetRoundTripTimeVariance() uint32
GetLastRoundTripTimeVariance() uint32
GetHighestRoundTripTimeVariance() uint32
}
type enetPeer struct {
@ -151,3 +159,28 @@ func (peer enetPeer) GetData() []byte {
C.int(binary.LittleEndian.Uint32(header)),
))
}
// rtt impl
func (peer enetPeer) GetRoundTripTime() uint32 {
return uint32(peer.cPeer.roundTripTime)
}
func (peer enetPeer) GetLastRoundTripTime() uint32 {
return uint32(peer.cPeer.lastRoundTripTime)
}
func (peer enetPeer) GetLowestRoundTripTime() uint32 {
return uint32(peer.cPeer.lowestRoundTripTime)
}
func (peer enetPeer) GetRoundTripTimeVariance() uint32 {
return uint32(peer.cPeer.roundTripTimeVariance)
}
func (peer enetPeer) GetLastRoundTripTimeVariance() uint32 {
return uint32(peer.cPeer.lastRoundTripTimeVariance)
}
func (peer enetPeer) GetHighestRoundTripTimeVariance() uint32 {
return uint32(peer.cPeer.highestRoundTripTimeVariance)
}