1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-06-26 00:55:23 +00:00
OpenDiablo2/d2networking/d2netpacket/net_packet.go
danhale-git 5ea6ada452
D2networking resolve lint issues (#492)
* Added automap.go stub

* Handle errors in original AutoMap.txt file

* Completed AutoMapRecord struct and comments

* AutoMap loader implemented

* Update from base repo

* Comments added to d2netpacket and d2netpackettype.

Note, the Overview for d2netpacket is in net_packet.go. It could be placed in a doc.go file but net_packet.go seemed appropriate in this case.

* Comments added to d2server

* client_connection.go missed from previous commit

* Comments added to d2client

* Doc.go added to d2networking and other corrections
2020-06-29 17:01:26 -04:00

24 lines
1.1 KiB
Go

// Package d2netpacket defines types which are encoded to JSON and sent in network
// packet payloads.
/*
Package d2netpacket/d2netpackettype defines a uint32 enumerable representing each
packet type.
A struct is defined for each packet type. Each struct comes with a function which
returns a NetPacket declaring the type enum (header) followed by the associated
struct (body). The NetPacket is marshalled to JSON for transport. On receipt of
the packet, the enum is read as a single byte then the remaining data (the struct)
is unmarshalled to the type associated with the type enum.*/
package d2netpacket
import "github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
// NetPacket is used to wrap and send all packet types under d2netpacket.
// When decoding a packet: First the PacketType byte is read, then the
// PacketData is unmarshalled to a struct of the type associated with
// PacketType.
type NetPacket struct {
PacketType d2netpackettype.NetPacketType `json:"packetType"`
PacketData interface{} `json:"packetData"`
}