connections

package
v4.2.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 13 Imported by: 6

Documentation

Index

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) BroadcastMessageTimeout

func (cg *ConnectionGroup) BroadcastMessageTimeout(message string, timeout time.Duration) bool

func (*ConnectionGroup) GetCount

func (cg *ConnectionGroup) GetCount() int

func (*ConnectionGroup) GetLimit

func (cg *ConnectionGroup) GetLimit() int

func (*ConnectionGroup) GetObjects

func (cg *ConnectionGroup) GetObjects() []interface{}

func (*ConnectionGroup) GetRate

func (cg *ConnectionGroup) GetRate() uint32

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) error

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 (*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, gamePreparedMessages <-chan *websocket.PreparedMessage) 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 ErrHandleConnection

type ErrHandleConnection struct {
	Err error
}

func (*ErrHandleConnection) Error

func (e *ErrHandleConnection) 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"`
}

ffjson: noencoder

func (*InputMessage) UnmarshalJSON

func (j *InputMessage) UnmarshalJSON(input []byte) error

UnmarshalJSON umarshall json - template of ffjson

func (*InputMessage) UnmarshalJSONFFLexer

func (j *InputMessage) UnmarshalJSONFFLexer(fs *fflib.FFLexer, state fflib.FFParseState) error

UnmarshalJSONFFLexer fast json unmarshall - template ffjson

type InputMessageType

type InputMessageType uint8
const (
	InputMessageTypeSnakeCommand InputMessageType = iota
	InputMessageTypeBroadcast
)

func (InputMessageType) String

func (t InputMessageType) String() string

func (*InputMessageType) UnmarshalJSON

func (t *InputMessageType) UnmarshalJSON(data []byte) error

type OutputMessage

type OutputMessage struct {
	Type    OutputMessageType `json:"type"`
	Payload interface{}       `json:"payload"`
}

ffjson: nodecoder

func (*OutputMessage) MarshalJSON

func (j *OutputMessage) MarshalJSON() ([]byte, error)

MarshalJSON marshal bytes to json - template

func (*OutputMessage) MarshalJSONBuf

func (j *OutputMessage) MarshalJSONBuf(buf fflib.EncodingBuffer) error

MarshalJSONBuf marshal buff to json - template

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

Jump to

Keyboard shortcuts

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