Exemplo n.º 1
0
// enet_host_create
func CreateHost(address *net.UDPAddr, peerCount uint, channelLimit uint, incomingBandwidth uint32, outgoingBandwith uint32) (*Host, error) {
	var c_host *C.ENetHost
	if address != nil {
		c_addr := conv_addr(address)
		c_host = C.enet_host_create(&c_addr, C.size_t(peerCount), C.size_t(channelLimit),
			C.enet_uint32(incomingBandwidth), C.enet_uint32(outgoingBandwith))
	} else {
		c_host = C.enet_host_create(nil, C.size_t(peerCount), C.size_t(channelLimit),
			C.enet_uint32(incomingBandwidth), C.enet_uint32(outgoingBandwith))
	}

	if c_host == nil {
		return nil, errors.New("ENet failed to create an ENetHost.")
	}
	C.enet_host_compress(c_host, nil)
	return &Host{c_host, make(map[*C.ENetPeer]*Peer)}, nil
}
Exemplo n.º 2
0
Arquivo: host.go Projeto: boj/goenet
func NewHost(a *ENetAddress, peerCount, channelLimit int, incomingBandwidth, outgoingBandwidth int) *ENetHost {
	return (*ENetHost)(C.enet_host_create((*C.ENetAddress)(a), C.size_t(peerCount), C.size_t(channelLimit), C.enet_uint32(incomingBandwidth), C.enet_uint32(outgoingBandwidth)))
}