mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-11-17 18:06:03 -05:00
aa680d030f
* Implement ServerFullPacket including server side handling and a place holder client side. * Making suggested edits to move to an empty packet Co-authored-by: Stephen Horan <steve.horan@theatsgroup.com>
39 lines
893 B
Go
39 lines
893 B
Go
package d2netpacket
|
|
|
|
import (
|
|
"encoding/json"
|
|
"log"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
)
|
|
|
|
// ServerFullPacket is sent by the server to inform a client that the
|
|
// server has reached the max number of allowed connections.
|
|
type ServerFullPacket struct{}
|
|
|
|
// CreateServerFullPacket returns a NetPacket which declares a ServerFullPacket.
|
|
func CreateServerFullPacket() NetPacket {
|
|
serverClosed := ServerFullPacket{}
|
|
|
|
b, err := json.Marshal(serverClosed)
|
|
if err != nil {
|
|
log.Print(err)
|
|
}
|
|
|
|
return NetPacket{
|
|
PacketType: d2netpackettype.ServerFull,
|
|
PacketData: b,
|
|
}
|
|
}
|
|
|
|
// UnmarshalServerFull unmarshalls the given data to a ServerFullPacket struct
|
|
func UnmarshalServerFull(packet []byte) (ServerFullPacket, error) {
|
|
var resp ServerFullPacket
|
|
|
|
if err := json.Unmarshal(packet, &resp); err != nil {
|
|
return resp, err
|
|
}
|
|
|
|
return resp, nil
|
|
}
|