Documentation ¶
Index ¶
- Variables
- type ConnectionGroup
- func (cg *ConnectionGroup) GetCount() int
- func (cg *ConnectionGroup) GetLimit() int
- func (cg *ConnectionGroup) GetWorldHeight() uint8
- func (cg *ConnectionGroup) GetWorldWidth() uint8
- func (cg *ConnectionGroup) Handle(connectionWorker *ConnectionWorker) *ErrRunConnection
- func (cg *ConnectionGroup) IsEmpty() bool
- func (cg *ConnectionGroup) IsFull() bool
- func (cg *ConnectionGroup) SetLimit(limit int)
- func (cg *ConnectionGroup) Start()
- func (cg *ConnectionGroup) Stop()
- type ConnectionGroupManager
- func (m *ConnectionGroupManager) Add(group *ConnectionGroup) (int, error)
- func (m *ConnectionGroupManager) Capacity() float32
- func (m *ConnectionGroupManager) Delete(group *ConnectionGroup) error
- func (m *ConnectionGroupManager) Get(id int) (*ConnectionGroup, error)
- func (m *ConnectionGroupManager) GroupCount() int
- func (m *ConnectionGroupManager) GroupLimit() int
- func (m *ConnectionGroupManager) Groups() map[int]*ConnectionGroup
- func (m *ConnectionGroupManager) IsFull() bool
- type ConnectionWorker
- type ErrAddGroup
- type ErrDeleteGroup
- type ErrRunConnection
- type ErrStartConnectionWorker
- type InputMessage
- type InputMessageType
- type OutputMessage
- type OutputMessageType
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrGroupLimitReached = ErrAddGroup("limit group count reached") ErrCannotGetID = ErrAddGroup("cannot get id for group") ErrConnsLimitReached = ErrAddGroup("cannot reserve connections for group: connections count reached") )
View Source
var ( ErrDeleteNotEmptyGroup = ErrDeleteGroup("group is not empty") ErrDeleteNotFoundGroup = ErrDeleteGroup("group not found") )
View Source
var ErrGroupIsFull = errors.New("group is full")
View Source
var ErrNotFoundGroup = errors.New("not found group")
View Source
var ErrUnknownInputMessageType = errors.New("unknown input message type")
Functions ¶
This section is empty.
Types ¶
type ConnectionGroup ¶
type ConnectionGroup struct {
// contains filtered or unexported fields
}
func NewConnectionGroup ¶
func NewConnectionGroup(logger logrus.FieldLogger, connectionLimit int, width, height uint8) (*ConnectionGroup, error)
func (*ConnectionGroup) GetCount ¶
func (cg *ConnectionGroup) GetCount() int
func (*ConnectionGroup) GetLimit ¶
func (cg *ConnectionGroup) GetLimit() int
func (*ConnectionGroup) GetWorldHeight ¶
func (cg *ConnectionGroup) GetWorldHeight() uint8
func (*ConnectionGroup) GetWorldWidth ¶
func (cg *ConnectionGroup) GetWorldWidth() uint8
func (*ConnectionGroup) Handle ¶
func (cg *ConnectionGroup) Handle(connectionWorker *ConnectionWorker) *ErrRunConnection
func (*ConnectionGroup) IsEmpty ¶
func (cg *ConnectionGroup) IsEmpty() bool
func (*ConnectionGroup) IsFull ¶
func (cg *ConnectionGroup) IsFull() bool
func (*ConnectionGroup) SetLimit ¶
func (cg *ConnectionGroup) SetLimit(limit int)
func (*ConnectionGroup) Start ¶
func (cg *ConnectionGroup) Start()
func (*ConnectionGroup) Stop ¶
func (cg *ConnectionGroup) Stop()
type ConnectionGroupManager ¶
type ConnectionGroupManager struct {
// contains filtered or unexported fields
}
func NewConnectionGroupManager ¶
func NewConnectionGroupManager(logger logrus.FieldLogger, groupLimit, connsLimit int) (*ConnectionGroupManager, error)
func (*ConnectionGroupManager) Add ¶
func (m *ConnectionGroupManager) Add(group *ConnectionGroup) (int, error)
func (*ConnectionGroupManager) Capacity ¶
func (m *ConnectionGroupManager) Capacity() float32
func (*ConnectionGroupManager) Delete ¶
func (m *ConnectionGroupManager) Delete(group *ConnectionGroup) error
func (*ConnectionGroupManager) Get ¶
func (m *ConnectionGroupManager) Get(id int) (*ConnectionGroup, error)
func (*ConnectionGroupManager) GroupCount ¶
func (m *ConnectionGroupManager) GroupCount() int
func (*ConnectionGroupManager) GroupLimit ¶
func (m *ConnectionGroupManager) GroupLimit() int
func (*ConnectionGroupManager) Groups ¶
func (m *ConnectionGroupManager) Groups() map[int]*ConnectionGroup
func (*ConnectionGroupManager) IsFull ¶
func (m *ConnectionGroupManager) IsFull() bool
type ConnectionWorker ¶
type ConnectionWorker struct {
// contains filtered or unexported fields
}
func NewConnectionWorker ¶
func NewConnectionWorker(conn *websocket.Conn, logger logrus.FieldLogger) *ConnectionWorker
func (*ConnectionWorker) Start ¶
func (cw *ConnectionWorker) Start(stop <-chan struct{}, game *game.Game, broadcast *broadcast.GroupBroadcast) error
type ErrAddGroup ¶
type ErrAddGroup string
func (ErrAddGroup) Error ¶
func (e ErrAddGroup) Error() string
type ErrDeleteGroup ¶
type ErrDeleteGroup string
func (ErrDeleteGroup) Error ¶
func (e ErrDeleteGroup) Error() string
type ErrRunConnection ¶
type ErrRunConnection struct {
Err error
}
func (*ErrRunConnection) Error ¶
func (e *ErrRunConnection) Error() string
type ErrStartConnectionWorker ¶
type ErrStartConnectionWorker string
func (ErrStartConnectionWorker) Error ¶
func (e ErrStartConnectionWorker) Error() string
type InputMessage ¶
type InputMessage struct { Type InputMessageType `json:"type"` Payload string `json:"payload"` }
type InputMessageType ¶
type InputMessageType uint8
const ( InputMessageTypeSnakeCommand InputMessageType = iota InputMessageTypeBroadcast )
func (*InputMessageType) UnmarshalJSON ¶
func (t *InputMessageType) UnmarshalJSON(data []byte) error
type OutputMessage ¶
type OutputMessage struct { Type OutputMessageType `json:"type"` Payload interface{} `json:"payload"` }
type OutputMessageType ¶
type OutputMessageType uint8
const ( OutputMessageTypeGame OutputMessageType = iota OutputMessageTypePlayer OutputMessageTypeBroadcast )
func (OutputMessageType) MarshalJSON ¶
func (t OutputMessageType) MarshalJSON() ([]byte, error)
func (OutputMessageType) String ¶
func (t OutputMessageType) String() string
Click to show internal directories.
Click to hide internal directories.