conngroup

package
v0.0.0-...-8667f16 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2020 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Size is the number of connections of this group.
	Size int

	// GenConn is the connection generator function.
	GenConn func() (messageconn.Conn, error)

	// EnableHeartBeat for the ws connections.
	EnableHeartBeat bool

	// HeartBeatInterval is how often to send a heart beat message.
	HeartBeatInterval time.Duration
}

type Conn

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

func NewConn

func NewConn(conn messageconn.Conn) *Conn

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) ReadMessage

func (c *Conn) ReadMessage() (msg []byte, err error)

func (*Conn) ReplaceConn

func (c *Conn) ReplaceConn(conn messageconn.Conn)

func (*Conn) SetUnusable

func (c *Conn) SetUnusable()

func (*Conn) SetUsable

func (c *Conn) SetUsable()

func (*Conn) Usable

func (c *Conn) Usable() bool

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(msg []byte) error

type ConnGroup

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

ConnGroup is a group of few connections.

func New

func New(config *Config) *ConnGroup

NewWSConn return a new instance of ConnGroup.

func (*ConnGroup) AddConn

func (cg *ConnGroup) AddConn(netConn messageconn.Conn)

func (*ConnGroup) Close

func (cg *ConnGroup) Close()

func (*ConnGroup) ReadMessage

func (cg *ConnGroup) ReadMessage() ([]byte, error)

func (*ConnGroup) Size

func (cg *ConnGroup) Size() int

func (*ConnGroup) WriteMessage

func (cg *ConnGroup) WriteMessage(p []byte) error

type ConnList

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

ConnList is a circle linked list of connections.

func NewList

func NewList() *ConnList

NewList return a new instance of ConnList.

func (*ConnList) Add

func (cl *ConnList) Add(conn *Conn)

func (*ConnList) ForEach

func (cl *ConnList) ForEach(f func(*Conn))

func (*ConnList) GetCurConn

func (cl *ConnList) GetCurConn() *Conn

func (*ConnList) Next

func (cl *ConnList) Next() *Conn

Next shift connection to the next one.

func (*ConnList) Remove

func (cl *ConnList) Remove(c *Conn)

func (*ConnList) Size

func (cl *ConnList) Size() int

Jump to

Keyboard shortcuts

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