Documentation ¶
Index ¶
- Constants
- func OnPlayerMove(c *Client, p Packet)
- func OnPlayerRespawn(c *Client, p Packet)
- func OnWelcomePacket(c *Client, p Packet)
- func PlayerEnterGame(c *Client)
- func StartServer()
- func TestGenerator()
- type Client
- type EnterGame
- type ID
- type IDGenerator
- type Job
- type LoginError
- type Packet
- func NewEnterGame(id ID, name string) Packet
- func NewLoginError(error string) Packet
- func NewPlayerMove(transfrom PlayerTransform) Packet
- func NewPlayerRespawn() Packet
- func NewRemovePlayer(playerID ID) Packet
- func NewSpawnPlayer(playerTransform PlayerTransform, playerInfo PlayerInfo) Packet
- func NewWelcome(name string) Packet
- type PacketID
- type PlayerInfo
- type PlayerMove
- type PlayerRespawn
- type PlayerTransform
- type RemovePlayer
- type Server
- type SpawnPlayer
- type Welcome
Constants ¶
View Source
const ( ID_Welcome = PacketID(iota) ID_EnterGame = PacketID(iota) ID_LoginError = PacketID(iota) ID_SpawnPlayer = PacketID(iota) ID_PlayerInfo = PacketID(iota) ID_PlayerTransform = PacketID(iota) ID_RemovePlayer = PacketID(iota) ID_PlayerMove = PacketID(iota) ID_Respawn = PacketID(iota) )
Variables ¶
This section is empty.
Functions ¶
func OnPlayerMove ¶
func OnPlayerRespawn ¶
func OnWelcomePacket ¶
func PlayerEnterGame ¶
func PlayerEnterGame(c *Client)
func StartServer ¶
func StartServer()
func TestGenerator ¶
func TestGenerator()
Types ¶
type Client ¶
type Client struct { Socket *net.TCPConn ID ID Name string X, Y float32 Rotation float32 Decoder *gob.Decoder Encoder *gob.Encoder Disconnected int32 }
func (*Client) HandlePacket ¶
type IDGenerator ¶
type IDGenerator struct {
// contains filtered or unexported fields
}
func NewIDGenerator ¶
func NewIDGenerator(buffer int, threadSafe bool) *IDGenerator
func (*IDGenerator) NextID ¶
func (gen *IDGenerator) NextID() ID
func (*IDGenerator) PutID ¶
func (gen *IDGenerator) PutID(id ID)
type LoginError ¶
type LoginError struct {
Error string
}
func (LoginError) ID ¶
func (e LoginError) ID() PacketID
type Packet ¶
type Packet interface {
ID() PacketID
}
func NewEnterGame ¶
func NewLoginError ¶
func NewPlayerMove ¶
func NewPlayerMove(transfrom PlayerTransform) Packet
func NewPlayerRespawn ¶
func NewPlayerRespawn() Packet
func NewRemovePlayer ¶
func NewSpawnPlayer ¶
func NewSpawnPlayer(playerTransform PlayerTransform, playerInfo PlayerInfo) Packet
func NewWelcome ¶
type PlayerInfo ¶
func NewPlayerInfo ¶
func NewPlayerInfo(playerID ID, name string) PlayerInfo
func (PlayerInfo) ID ¶
func (s PlayerInfo) ID() PacketID
type PlayerMove ¶
type PlayerMove struct {
PlayerTransform
}
func (PlayerMove) ID ¶
func (s PlayerMove) ID() PacketID
type PlayerRespawn ¶
type PlayerRespawn struct { }
func (PlayerRespawn) ID ¶
func (s PlayerRespawn) ID() PacketID
type PlayerTransform ¶
func NewPlayerTransform ¶
func NewPlayerTransform(playerID ID, X, Y, Rotation float32) PlayerTransform
func (PlayerTransform) ID ¶
func (s PlayerTransform) ID() PacketID
type RemovePlayer ¶
type RemovePlayer struct {
PlayerID ID
}
func (RemovePlayer) ID ¶
func (s RemovePlayer) ID() PacketID
type Server ¶
type Server struct { Socket *net.TCPListener Clients map[ID]*Client Jobs chan Job IDGen *IDGenerator }
var MainServer *Server
type SpawnPlayer ¶
type SpawnPlayer struct { PlayerTransform PlayerInfo }
func (SpawnPlayer) ID ¶
func (s SpawnPlayer) ID() PacketID
Source Files ¶
Click to show internal directories.
Click to hide internal directories.