diff --git a/host/lux_host.go b/host/lux_host.go index 1b644eb..e1ef602 100644 --- a/host/lux_host.go +++ b/host/lux_host.go @@ -59,7 +59,7 @@ func (host *LuxHost) Heartbeat() error { packet := net.LuxPacket{ Target: host.router.GetThisKey().Id, - Type: 0x6969, // FIXME + Type: net.LuxPacketTypeHeartbeat, Buffer: proto.NewLuxBuffer(), } diff --git a/net/lux_packet.go b/net/lux_packet.go index a5b7389..edfdecb 100644 --- a/net/lux_packet.go +++ b/net/lux_packet.go @@ -11,6 +11,13 @@ import ( "net" ) +type LuxPacketType uint + +const ( + LuxPacketTypeHeartbeat = 0 + LuxPacketTypeSync = 1 +) + const LUX_PROTO_PACKET_HDRLEN = proto.LUX_PROTO_ID_SIZE + 2 // Target, Type are decoded from header @@ -22,7 +29,7 @@ const LUX_PROTO_PACKET_HDRLEN = proto.LUX_PROTO_ID_SIZE + 2 // associated key with route. type LuxPacket struct { Target proto.LuxID - Type uint + Type LuxPacketType Buffer proto.LuxBuffer ChannelType LuxChannelType } @@ -51,7 +58,7 @@ func DecryptLuxPacket(dgram LuxDatagram, key crypto.LuxKey) (LuxPacket, error) { } if pType, err := packet.Buffer.ReadUint16(); err == nil { - packet.Type = uint(pType) + packet.Type = LuxPacketType(pType) } else { return packet, err }