2020-06-18 14:11:04 -04:00
|
|
|
package d2netpacket
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2game/d2player"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2networking/d2netpacket/d2netpackettype"
|
|
|
|
)
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// PlayerConnectionRequestPacket contains a player ID and game state.
|
|
|
|
// It is sent by a remote client to initiate a connection (join a game).
|
2020-06-18 14:11:04 -04:00
|
|
|
type PlayerConnectionRequestPacket struct {
|
2020-07-17 22:11:16 -04:00
|
|
|
ID string `json:"id"`
|
2020-06-18 14:11:04 -04:00
|
|
|
PlayerState *d2player.PlayerState `json:"gameState"`
|
|
|
|
}
|
|
|
|
|
2020-06-29 17:01:26 -04:00
|
|
|
// CreatePlayerConnectionRequestPacket returns a NetPacket which defines a
|
|
|
|
// PlayerConnectionRequestPacket with the given ID and game state.
|
2020-06-18 14:11:04 -04:00
|
|
|
func CreatePlayerConnectionRequestPacket(id string, playerState *d2player.PlayerState) NetPacket {
|
|
|
|
return NetPacket{
|
|
|
|
PacketType: d2netpackettype.PlayerConnectionRequest,
|
|
|
|
PacketData: PlayerConnectionRequestPacket{
|
2020-07-17 22:11:16 -04:00
|
|
|
ID: id,
|
2020-06-18 14:11:04 -04:00
|
|
|
PlayerState: playerState,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|