示例#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
}
示例#2
0
文件: peer.go 项目: hycxa/waiter
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}
}
示例#3
0
文件: packet.go 项目: boj/goenet
// 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)))
}