Merge pull request #4 from jessehorne/master

Added enet_host_compress_with_range_coder binding
This commit is contained in:
Melissa 2022-10-18 11:46:04 +02:00 committed by GitHub
commit bd2e8a9be1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

14
host.go
View file

@ -12,6 +12,8 @@ type Host interface {
Service(timeout uint32) Event
Connect(addr Address, channelCount int, data uint32) (Peer, error)
CompressWithRangeCoder() error
}
type enetHost struct {
@ -49,6 +51,18 @@ func (host *enetHost) Connect(addr Address, channelCount int, data uint32) (Peer
}, nil
}
func (host *enetHost) CompressWithRangeCoder() error {
status := C.enet_host_compress_with_range_coder(host.cHost)
if status == -1 {
return errors.New("couldn't set the packet compressor to default range coder because context is nil")
} else if status != 0 {
return errors.New("couldn't set the packet compressor to default range coder for unknown reason")
}
return nil
}
// NewHost creats a host for communicating to peers
func NewHost(addr Address, peerCount, channelLimit uint64, incomingBandwidth, outgoingBandwidth uint32) (Host, error) {
var cAddr *C.struct__ENetAddress