server

package
v0.0.0-...-bf9f9cd Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AvgWorldUpdateTime time.Duration

Functions

func CreatePollNetworkSystem

func CreatePollNetworkSystem(world *ecs.World, networkChannel chan serdes.WorldUpdate) ecs.System

TODO - this kindof represents a greater pattern of trying to apply commands to the world in a threadsafe manner. Maybe integrate this into the ECS library: https://docs.rs/bevy/0.4.0/bevy/ecs/trait.Command.html

func CreateServerSystems

func CreateServerSystems(world *ecs.World, server *Server, networkChannel chan serdes.WorldUpdate, deleteList *DeleteList, tilemap *tile.Tilemap) []ecs.System

func Main

func Main()

func ServeProxyConnection

func ServeProxyConnection(serverConn *ServerConn, world *ecs.World, networkChannel chan serdes.WorldUpdate, deleteList *DeleteList) error

func ServerSendUpdate

func ServerSendUpdate(world *ecs.World, server *Server, deleteList *DeleteList)

This calculates the update to send to all players, finds the proxy associated with them, and sends that update over the wire

Types

type ClientTick

type ClientTick struct {
	Tick uint16 // This is the tick that the player is currently on
}

This is the tick that the client says they are on

type DeleteList

type DeleteList struct {
	// contains filtered or unexported fields
}

-------------------------------------------------------------------------------- - Server --------------------------------------------------------------------------------

func NewDeleteList

func NewDeleteList() *DeleteList

func (*DeleteList) Append

func (d *DeleteList) Append(id ecs.Id)

func (*DeleteList) CopyAndClear

func (d *DeleteList) CopyAndClear() []ecs.Id

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(listener net.Listener, handler func(*ServerConn) error) *Server

func (*Server) AddProxy

func (s *Server) AddProxy(proxyId uint64, conn *ServerConn)

func (*Server) GetProxy

func (s *Server) GetProxy(proxyId uint64) (*ServerConn, bool)

func (*Server) RemoveProxy

func (s *Server) RemoveProxy(proxyId uint64)

func (*Server) Start

func (s *Server) Start()

type ServerConn

type ServerConn struct {
	// contains filtered or unexported fields
}

--------------------------------------------------------------------------------

func (*ServerConn) GetStats

func (c *ServerConn) GetStats() int

TODO - add more stats

func (*ServerConn) GetUser

func (c *ServerConn) GetUser(userId uint64) (ecs.Id, bool)

func (*ServerConn) LoginUser

func (c *ServerConn) LoginUser(userId uint64, ecsId ecs.Id)

func (*ServerConn) LogoutUser

func (c *ServerConn) LogoutUser(userId uint64)

func (*ServerConn) Recv

func (c *ServerConn) Recv() (any, error)

func (*ServerConn) Send

func (c *ServerConn) Send(msg any) error

type User

type User struct {
	// Name string // TODO - remove and put into a component called "DisplayName"
	Id      uint64
	ProxyId uint64
}

Represents a logged in user on the server

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL