mirror of
https://github.com/codecat/go-enet.git
synced 2025-12-08 05:59:47 +00:00
Merge pull request #4 from jessehorne/master
Added enet_host_compress_with_range_coder binding
This commit is contained in:
commit
bd2e8a9be1
1 changed files with 14 additions and 0 deletions
14
host.go
14
host.go
|
|
@ -12,6 +12,8 @@ type Host interface {
|
||||||
Service(timeout uint32) Event
|
Service(timeout uint32) Event
|
||||||
|
|
||||||
Connect(addr Address, channelCount int, data uint32) (Peer, error)
|
Connect(addr Address, channelCount int, data uint32) (Peer, error)
|
||||||
|
|
||||||
|
CompressWithRangeCoder() error
|
||||||
}
|
}
|
||||||
|
|
||||||
type enetHost struct {
|
type enetHost struct {
|
||||||
|
|
@ -49,6 +51,18 @@ func (host *enetHost) Connect(addr Address, channelCount int, data uint32) (Peer
|
||||||
}, nil
|
}, 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
|
// NewHost creats a host for communicating to peers
|
||||||
func NewHost(addr Address, peerCount, channelLimit uint64, incomingBandwidth, outgoingBandwidth uint32) (Host, error) {
|
func NewHost(addr Address, peerCount, channelLimit uint64, incomingBandwidth, outgoingBandwidth uint32) (Host, error) {
|
||||||
var cAddr *C.struct__ENetAddress
|
var cAddr *C.struct__ENetAddress
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue