conn

package
v0.3.37 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultReadBuffSize = 8 * 1024
View Source
const DefaultWriteBuffSize = 16 * 1024
View Source
const MinMergedWriteBuffSize = 100 * 1024
View Source
const ProtectLongPacketSize = 8 * 1024 * 1024

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	net.Conn

	Session  lokas.ISession
	UserData interface{}
	ConnTime time.Time
	// contains filtered or unexported fields
}

func NewTcpConn

func NewTcpConn(c net.Conn, context *lokas.Context, hub *hub.Hub) *Conn

func NewWsConn

func NewWsConn(c *websocket.Conn, context *lokas.Context, hub *hub.Hub) *Conn

func (*Conn) Activate

func (this *Conn) Activate()

func (*Conn) Close

func (this *Conn) Close() error

func (*Conn) GetConnTime

func (this *Conn) GetConnTime() time.Time

func (*Conn) GetSession

func (this *Conn) GetSession() lokas.ISession

func (*Conn) GetUserData

func (this *Conn) GetUserData() interface{}

func (*Conn) ServeIO

func (this *Conn) ServeIO()

func (*Conn) SetUserData

func (this *Conn) SetUserData(userData interface{})

func (*Conn) Wait

func (this *Conn) Wait()

func (*Conn) Write

func (this *Conn) Write(data []byte) (int, error)

type DataBuff

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

func NewDataBuff

func NewDataBuff(buffSize int, enabled bool) *DataBuff

func (*DataBuff) GetData

func (this *DataBuff) GetData(data []byte, c <-chan []byte) ([]byte, int)

GetData return merged buff from channel c

func (*DataBuff) WriteData

func (this *DataBuff) WriteData(data []byte, c <-chan []byte, spilt func(data []byte) ([][]byte, error), maxPacketWriteLen int, write func(rb []byte, count int) error) error

type DefaultMessageChan

type DefaultMessageChan struct {
	In  chan<- []byte
	Out <-chan []byte
	// contains filtered or unexported fields
}

func NewDefaultMessageChan

func NewDefaultMessageChan(size int, done chan struct{}) *DefaultMessageChan

func (*DefaultMessageChan) GetInChan

func (this *DefaultMessageChan) GetInChan() chan<- []byte

func (*DefaultMessageChan) GetOutChan

func (this *DefaultMessageChan) GetOutChan() <-chan []byte

func (*DefaultMessageChan) Len

func (this *DefaultMessageChan) Len() int

type IOPumper

type IOPumper interface {
	// contains filtered or unexported methods
}

type IdleChecker

type IdleChecker struct {
	InitConnChan   chan lokas.IConn
	ActiveConnChan chan lokas.IConn
	CloseConnChan  chan lokas.IConn
	// contains filtered or unexported fields
}

func NewIdleChecker

func NewIdleChecker(duration time.Duration) *IdleChecker

func (*IdleChecker) Stop

func (this *IdleChecker) Stop()

type MessageChan

type MessageChan interface {
	GetInChan() chan<- []byte
	GetOutChan() <-chan []byte
	Len() int
}

func NewMessageChan

func NewMessageChan(useNoneBlocking bool, size int, done chan struct{}) MessageChan

type NonBlockingMessageChan

type NonBlockingMessageChan struct {
	*DefaultMessageChan
	// contains filtered or unexported fields
}

Special type that mimics the behavior of a channel but does not block when items are sent. Items are stored internally until received. Closing the Send channel will cause the Recv channel to be closed after all items have been received.

func NewNonBlockingMessageChan

func NewNonBlockingMessageChan(size int, done chan struct{}) *NonBlockingMessageChan

OnCreate a new non-blocking channel.

func (*NonBlockingMessageChan) Len

func (this *NonBlockingMessageChan) Len() int

Retrieve the number of items waiting to be received.

type TcpPumper

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

type WsConnWrapper

type WsConnWrapper struct {
	*websocket.Conn
}

wrap websocket.IConn to adopt net.IConn

func (*WsConnWrapper) Read

func (this *WsConnWrapper) Read(b []byte) (int, error)

func (*WsConnWrapper) SetDeadline

func (this *WsConnWrapper) SetDeadline(t time.Time) error

func (*WsConnWrapper) Write

func (this *WsConnWrapper) Write(data []byte) (int, error)

type WsPumper

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

Jump to

Keyboard shortcuts

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