Documentation ¶
Overview ¶
Package packet is for TCP and UDP packets used in eX0 networking protocol.
Index ¶
- Constants
- type BroadcastTextMessage
- type ClientCommand
- type CurrentPlayersInfo
- type EnterGamePermission
- type EnteredGameNotification
- type Handshake
- type JoinServerAccept
- type JoinServerRefuse
- type JoinServerRequest
- type JoinTeamRequest
- type LoadLevel
- type LocalPlayerInfo
- type Move
- type Ping
- type PlayerInfo
- type PlayerJoinedServer
- type PlayerJoinedTeam
- type PlayerLeftServer
- type PlayerUpdate
- type PlayerWasHit
- type Pong
- type Pung
- type SendTextMessage
- type ServerUpdate
- type State
- type TCPHeader
- type Team
- type TimeRequest
- type TimeResponse
- type Type
- type UDPConnectionEstablished
- type UDPHeader
- type WeaponAction
- type WeaponCommand
- type WeaponState
Constants ¶
View Source
const MAX_TCP_SIZE = 1448
View Source
const MAX_UDP_SIZE = 1448
View Source
const TCPHeaderSize = 3
TCPHeaderSize is the size in bytes of the TCP packet header.
View Source
const UDPHeaderSize = 1
UDPHeaderSize is the size in bytes of the UDP packet header.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastTextMessage ¶
func (*BroadcastTextMessage) MarshalBinary ¶
func (p *BroadcastTextMessage) MarshalBinary() ([]byte, error)
func (*BroadcastTextMessage) UnmarshalBinary ¶
func (p *BroadcastTextMessage) UnmarshalBinary(b []byte) error
type ClientCommand ¶
type ClientCommand struct { UDPHeader CommandSequenceNumber uint8 // Latest command sequence number (i.e., last one in the slice). CommandSeriesNumber uint8 MovesCount uint8 // len(Moves) - 1. Moves []Move // Oldest first, newest last. }
func (*ClientCommand) MarshalBinary ¶
func (p *ClientCommand) MarshalBinary() ([]byte, error)
func (*ClientCommand) UnmarshalBinary ¶
func (p *ClientCommand) UnmarshalBinary(b []byte) error
type CurrentPlayersInfo ¶
type CurrentPlayersInfo struct { TCPHeader Players []PlayerInfo }
func (*CurrentPlayersInfo) MarshalBinary ¶
func (p *CurrentPlayersInfo) MarshalBinary() ([]byte, error)
func (*CurrentPlayersInfo) UnmarshalBinary ¶
func (p *CurrentPlayersInfo) UnmarshalBinary(b []byte, totalPlayerCount uint8) error
type EnterGamePermission ¶
type EnterGamePermission struct {
TCPHeader
}
func (*EnterGamePermission) MarshalBinary ¶
func (p *EnterGamePermission) MarshalBinary() ([]byte, error)
func (*EnterGamePermission) UnmarshalBinary ¶
func (p *EnterGamePermission) UnmarshalBinary(b []byte) error
type EnteredGameNotification ¶
type EnteredGameNotification struct {
TCPHeader
}
func (*EnteredGameNotification) MarshalBinary ¶
func (p *EnteredGameNotification) MarshalBinary() ([]byte, error)
func (*EnteredGameNotification) UnmarshalBinary ¶
func (p *EnteredGameNotification) UnmarshalBinary(b []byte) error
type JoinServerAccept ¶
func (*JoinServerAccept) MarshalBinary ¶
func (p *JoinServerAccept) MarshalBinary() ([]byte, error)
func (*JoinServerAccept) UnmarshalBinary ¶
func (p *JoinServerAccept) UnmarshalBinary(b []byte) error
type JoinServerRefuse ¶
func (*JoinServerRefuse) MarshalBinary ¶
func (p *JoinServerRefuse) MarshalBinary() ([]byte, error)
func (*JoinServerRefuse) UnmarshalBinary ¶
func (p *JoinServerRefuse) UnmarshalBinary(b []byte) error
type JoinServerRequest ¶
func (*JoinServerRequest) MarshalBinary ¶
func (p *JoinServerRequest) MarshalBinary() ([]byte, error)
func (*JoinServerRequest) UnmarshalBinary ¶
func (p *JoinServerRequest) UnmarshalBinary(b []byte) error
type JoinTeamRequest ¶
type JoinTeamRequest struct { TCPHeader PlayerNumber *uint8 // If > 1 players per connection, player index within the connection. Team Team }
func (*JoinTeamRequest) MarshalBinary ¶
func (p *JoinTeamRequest) MarshalBinary() ([]byte, error)
func (*JoinTeamRequest) UnmarshalBinary ¶
func (p *JoinTeamRequest) UnmarshalBinary(b []byte) error
type LocalPlayerInfo ¶
type LocalPlayerInfo struct { TCPHeader NameLength uint8 Name []byte CommandRate uint8 UpdateRate uint8 }
func (*LocalPlayerInfo) MarshalBinary ¶
func (p *LocalPlayerInfo) MarshalBinary() ([]byte, error)
func (*LocalPlayerInfo) UnmarshalBinary ¶
func (p *LocalPlayerInfo) UnmarshalBinary(b []byte) error
type Ping ¶
func (*Ping) MarshalBinary ¶
type PlayerInfo ¶
type PlayerJoinedServer ¶
func (*PlayerJoinedServer) MarshalBinary ¶
func (p *PlayerJoinedServer) MarshalBinary() ([]byte, error)
func (*PlayerJoinedServer) UnmarshalBinary ¶
func (p *PlayerJoinedServer) UnmarshalBinary(b []byte) error
type PlayerJoinedTeam ¶
func (*PlayerJoinedTeam) MarshalBinary ¶
func (p *PlayerJoinedTeam) MarshalBinary() ([]byte, error)
func (*PlayerJoinedTeam) UnmarshalBinary ¶
func (p *PlayerJoinedTeam) UnmarshalBinary(b []byte) error
type PlayerLeftServer ¶
func (*PlayerLeftServer) MarshalBinary ¶
func (p *PlayerLeftServer) MarshalBinary() ([]byte, error)
func (*PlayerLeftServer) UnmarshalBinary ¶
func (p *PlayerLeftServer) UnmarshalBinary(b []byte) error
type PlayerUpdate ¶
type PlayerWasHit ¶
func (*PlayerWasHit) MarshalBinary ¶
func (p *PlayerWasHit) MarshalBinary() ([]byte, error)
func (*PlayerWasHit) UnmarshalBinary ¶
func (p *PlayerWasHit) UnmarshalBinary(b []byte) error
type SendTextMessage ¶
func (*SendTextMessage) MarshalBinary ¶
func (p *SendTextMessage) MarshalBinary() ([]byte, error)
func (*SendTextMessage) UnmarshalBinary ¶
func (p *SendTextMessage) UnmarshalBinary(b []byte) error
type ServerUpdate ¶
type ServerUpdate struct { UDPHeader CurrentUpdateSequenceNumber uint8 PlayerUpdates []PlayerUpdate }
func (*ServerUpdate) MarshalBinary ¶
func (p *ServerUpdate) MarshalBinary() ([]byte, error)
func (*ServerUpdate) UnmarshalBinary ¶
func (p *ServerUpdate) UnmarshalBinary(b []byte, totalPlayerCount uint8) error
type TCPHeader ¶
func (*TCPHeader) UnmarshalBinary ¶
type TimeRequest ¶
func (*TimeRequest) MarshalBinary ¶
func (p *TimeRequest) MarshalBinary() ([]byte, error)
func (*TimeRequest) UnmarshalBinary ¶
func (p *TimeRequest) UnmarshalBinary(b []byte) error
type TimeResponse ¶
func (*TimeResponse) MarshalBinary ¶
func (p *TimeResponse) MarshalBinary() ([]byte, error)
func (*TimeResponse) UnmarshalBinary ¶
func (p *TimeResponse) UnmarshalBinary(b []byte) error
type Type ¶
type Type uint8
const ( // TCP packet types. JoinServerRequestType Type = 1 JoinServerAcceptType Type = 2 JoinServerRefuseType Type = 3 UDPConnectionEstablishedType Type = 5 EnterGamePermissionType Type = 6 EnteredGameNotificationType Type = 7 SendTextMessageType Type = 10 BroadcastTextMessageType Type = 11 LoadLevelType Type = 20 CurrentPlayersInfoType Type = 21 PlayerJoinedServerType Type = 25 PlayerLeftServerType Type = 26 JoinTeamRequestType Type = 27 PlayerJoinedTeamType Type = 28 LocalPlayerInfoType Type = 30 PlayerWasHitType Type = 40 // UDP packet types. ClientCommandType Type = 1 ServerUpdateType Type = 2 WeaponCommandType Type = 3 WeaponActionType Type = 4 PingType Type = 10 PongType Type = 11 PungType Type = 12 HandshakeType Type = 100 TimeRequestType Type = 105 TimeResponseType Type = 106 )
type UDPConnectionEstablished ¶
type UDPConnectionEstablished struct {
TCPHeader
}
func (*UDPConnectionEstablished) MarshalBinary ¶
func (p *UDPConnectionEstablished) MarshalBinary() ([]byte, error)
func (*UDPConnectionEstablished) UnmarshalBinary ¶
func (p *UDPConnectionEstablished) UnmarshalBinary(b []byte) error
type WeaponAction ¶
type WeaponAction struct { UDPHeader PlayerID uint8 Action WeaponState Time float64 Z float32 // If Action is WeaponSystem::FIRE. WeaponNumber uint8 // If Action is WeaponSystem::CHANGE_WEAPON. }
func (*WeaponAction) MarshalBinary ¶
func (p *WeaponAction) MarshalBinary() ([]byte, error)
func (*WeaponAction) UnmarshalBinary ¶
func (p *WeaponAction) UnmarshalBinary(b []byte) error
type WeaponCommand ¶
type WeaponCommand struct { UDPHeader Action WeaponState Time float64 Z float32 // If Action is WeaponSystem::FIRE. WeaponNumber uint8 // If Action is WeaponSystem::CHANGE_WEAPON. }
func (*WeaponCommand) MarshalBinary ¶
func (p *WeaponCommand) MarshalBinary() ([]byte, error)
func (*WeaponCommand) UnmarshalBinary ¶
func (p *WeaponCommand) UnmarshalBinary(b []byte) error
type WeaponState ¶
type WeaponState uint8
const ( Idle WeaponState = 0 Fire WeaponState = 1 Reload WeaponState = 2 ChangeWeapon WeaponState = 3 )
Click to show internal directories.
Click to hide internal directories.