Exemple #1
0
func new_packet(data []byte, flags Flag) *C.ENetPacket {
	c_packet := C.enet_packet_create(unsafe.Pointer(&data[0]), C.size_t(len(data)), C.enet_uint32(flags))
	if c_packet == nil {
		panic("Allocation failure inside ENet")
	}
	return c_packet
}
Exemple #2
0
func (p *Peer) Send(payload []byte, flags PacketFlag, channel uint8) {
	if len(payload) == 0 {
		return
	}

	packet := C.enet_packet_create(unsafe.Pointer(&payload[0]), C.size_t(len(payload)), C.enet_uint32(flags))
	p.out <- outgoingPacket{packet, channel}
}
Exemple #3
0
// Currently this method requires that the data be written in byte form.
// Ideally it would be nice to write arbitrary data such as one can do in the C ENet library.
func NewPacket(data []byte, dataLength int, flags ENetPacketFlag) *ENetPacket {
	return (*ENetPacket)(C.enet_packet_create(unsafe.Pointer(&data[0]), C.size_t(dataLength), C.enet_uint32(flags)))
}