Documentation
¶
Index ¶
- Variables
- type Command
- type CommandParser
- type CommunicateComponent
- func (c *CommunicateComponent) AddMessageToQueue(m OutgoingMessage)
- func (c *CommunicateComponent) Close() (err error)
- func (c *CommunicateComponent) GetIncoming() chan []byte
- func (c *CommunicateComponent) GetOutgoing() chan []byte
- func (c *CommunicateComponent) GetParser() CommandParser
- func (c *CommunicateComponent) GetQueue() [][]byte
- func (c *CommunicateComponent) InitChannels()
- func (c *CommunicateComponent) IsWaiting() bool
- func (c *CommunicateComponent) ProcessIncomingMessages(ctx context.Context, e []byte) error
- func (c *CommunicateComponent) ProcessOutgoingQueue()
- func (c *CommunicateComponent) Send(d OutgoingMessage)
- func (c *CommunicateComponent) SetParser(parser CommandParser)
- func (c *CommunicateComponent) StartReadingMessages(ctx context.Context)
- func (c *CommunicateComponent) Wait(w bool)
- func (c *CommunicateComponent) Write(d []byte)
- type Communication
- type CommunicationSystem
- type OutgoingMessage
Constants ¶
This section is empty.
Variables ¶
var (
ErrChannelsAlreadyClosed = errors.New("error channels already closed")
)
All kind of errors for game
Functions ¶
This section is empty.
Types ¶
type Command ¶
type Command interface {
GetMsgType() uint8
Decode(msg []byte)
Encode() []byte
Execute(ctx context.Context) error
}
Command interface for standard command
type CommandParser ¶
CommandParser command parser
type CommunicateComponent ¶
type CommunicateComponent struct {
// contains filtered or unexported fields
}
CommunicateComponent communication component
func NewCommunicateComponent ¶
func NewCommunicateComponent(conn net.Conn) *CommunicateComponent
NewCommunicateComponent return new communication component
func (*CommunicateComponent) AddMessageToQueue ¶
func (c *CommunicateComponent) AddMessageToQueue(m OutgoingMessage)
AddMessageToQueue add message to queue
func (*CommunicateComponent) Close ¶
func (c *CommunicateComponent) Close() (err error)
Close close channels
func (*CommunicateComponent) GetIncoming ¶
func (c *CommunicateComponent) GetIncoming() chan []byte
GetIncoming return incoming channel
func (*CommunicateComponent) GetOutgoing ¶
func (c *CommunicateComponent) GetOutgoing() chan []byte
GetOutgoing return outgoing channel
func (*CommunicateComponent) GetParser ¶
func (c *CommunicateComponent) GetParser() CommandParser
GetParser return command parser
func (*CommunicateComponent) GetQueue ¶
func (c *CommunicateComponent) GetQueue() [][]byte
GetQueue retun copy of queue
func (*CommunicateComponent) InitChannels ¶
func (c *CommunicateComponent) InitChannels()
InitChannels init channels
func (*CommunicateComponent) IsWaiting ¶
func (c *CommunicateComponent) IsWaiting() bool
IsWaiting return true if still wait
func (*CommunicateComponent) ProcessIncomingMessages ¶
func (c *CommunicateComponent) ProcessIncomingMessages(ctx context.Context, e []byte) error
ProcessIncomingMessages execute commands
func (*CommunicateComponent) ProcessOutgoingQueue ¶
func (c *CommunicateComponent) ProcessOutgoingQueue()
ProcessOutgoingQueue processing cache
func (*CommunicateComponent) Send ¶
func (c *CommunicateComponent) Send(d OutgoingMessage)
Send send message for player
func (*CommunicateComponent) SetParser ¶
func (c *CommunicateComponent) SetParser(parser CommandParser)
SetParser set command parser
func (*CommunicateComponent) StartReadingMessages ¶
func (c *CommunicateComponent) StartReadingMessages(ctx context.Context)
StartReadingMessages starting processing incoming messages
func (*CommunicateComponent) Wait ¶
func (c *CommunicateComponent) Wait(w bool)
Wait mark connection waiting
func (*CommunicateComponent) Write ¶
func (c *CommunicateComponent) Write(d []byte)
Write write data in chan
type Communication ¶
type Communication interface {
ProcessOutgoingQueue()
AddMessageToQueue(m OutgoingMessage)
GetIncoming() chan []byte
GetOutgoing() chan []byte
ProcessIncomingMessages(ctx context.Context, e []byte) error
Close() error
Write(d []byte)
}
Communication describe communication
type CommunicationSystem ¶
type CommunicationSystem struct {
// contains filtered or unexported fields
}
CommunicationSystem contains moveable entities
func NewCommunicationSystem ¶
func NewCommunicationSystem( reg *registry.Registry[any, any, any], workersCount int, keys ...interface{}, ) *CommunicationSystem
NewCommunicationSystem return new CommunicationSystem
func (*CommunicationSystem) EntitiesKeys ¶
func (c *CommunicationSystem) EntitiesKeys() []interface{}
EntitiesKeys return entities keys
type OutgoingMessage ¶
OutgoingMessage describe outgoing message