mirror of
https://github.com/CPunch/gopenfusion.git
synced 2025-11-06 23:50:20 +00:00
server: Client -> Peer
This commit is contained in:
@@ -10,13 +10,14 @@ import (
|
||||
)
|
||||
|
||||
/*
|
||||
this file handles serializing (and deserializing) structs to alignment-strict c structures
|
||||
this file handles serializing (and deserializing) structs to alignment-strict c structures generated via `tools/genstructs.py`.
|
||||
see script for details on usage!
|
||||
*/
|
||||
|
||||
type Packet struct {
|
||||
ByteOrder binary.ByteOrder
|
||||
Buf []byte
|
||||
cursor int // to keep track of things like member alignment
|
||||
cursor int // to keep track of things like member alignment for easier debugging
|
||||
}
|
||||
|
||||
const PACK_ALIGN = 4
|
||||
@@ -34,12 +35,6 @@ func (pkt *Packet) ResetCursor() {
|
||||
pkt.cursor = 0
|
||||
}
|
||||
|
||||
func (pkt *Packet) CompletePacket(typeID uint32) {
|
||||
tmp := make([]byte, 4)
|
||||
pkt.ByteOrder.PutUint32(tmp, typeID)
|
||||
pkt.Buf = append(tmp, pkt.Buf...)
|
||||
}
|
||||
|
||||
func (pkt *Packet) writeRaw(data []byte) {
|
||||
pkt.Buf = append(pkt.Buf, data...)
|
||||
pkt.cursor += len(data)
|
||||
|
||||
Reference in New Issue
Block a user