connection

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CHANNEL_PACKET_MAX = 1024
	Packet_Max_Len     = 2097152
)

Variables

This section is empty.

Functions

func BytesToInt32

func BytesToInt32(buf []byte) int32

func BytesToInt64

func BytesToInt64(buf []byte) int64

func Get added in v1.0.5

func Get[T any](conn IConnection, key int64) T

func Init added in v0.0.3

func Init(endian string)

func Int32ToBytes

func Int32ToBytes(num int32) []byte

func Int64ToBytes

func Int64ToBytes(num int64) []byte

Types

type Default

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

func NewDefault

func NewDefault() *Default

func (*Default) BodyOffset

func (d *Default) BodyOffset() int

func (*Default) LenOffset

func (d *Default) LenOffset() int

func (*Default) Serialize

func (d *Default) Serialize() []byte

func (*Default) Unserialize

func (d *Default) Unserialize(buf []byte) error

type IConnection

type IConnection interface {
	Read(int, int, int) ([]byte, error)
	Write([]byte) (int, error)
	Send(IPacket) error
	SendBytes([]byte) error
	Close() error
	FD() uint64
	WQueue() <-chan []byte
	Closed() bool
	RemoteIp() string
	Expired() bool
	Set(key int64, value any)
	Get(key int64) (any, bool)
	SQueue() <-chan bool
}

type IPacket

type IPacket interface {
	Serialize() []byte
	Unserialize([]byte) error
}

type PacketConfig

type PacketConfig struct {
	HeaderLength  int    `json:"header_length" yaml:"header_length"`
	BodyLenOffset int    `json:"body_length_offset" yaml:"body_length_offset"`
	BodyLenLen    int    `json:"body_length_len" yaml:"body_length_len"`
	Endian        string `json:"endian" yaml:"endian"`
}

type Tcp

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

func NewTcp

func NewTcp(fd uint64, conn net.Conn) *Tcp

func (*Tcp) Close

func (t *Tcp) Close() error

func (*Tcp) Closed

func (t *Tcp) Closed() bool

func (*Tcp) Expired added in v1.0.2

func (t *Tcp) Expired() bool

func (*Tcp) FD

func (t *Tcp) FD() uint64

func (*Tcp) Get added in v1.0.5

func (t *Tcp) Get(userId int64) (any, bool)

func (*Tcp) Read

func (t *Tcp) Read(hLen, bLen, bLenOffset int) ([]byte, error)

func (*Tcp) RemoteIp added in v0.1.2

func (t *Tcp) RemoteIp() string

func (*Tcp) SQueue added in v1.0.6

func (t *Tcp) SQueue() <-chan bool

func (*Tcp) Send added in v0.0.2

func (t *Tcp) Send(pack IPacket) error

func (*Tcp) SendBytes added in v0.0.5

func (t *Tcp) SendBytes(buf []byte) error

func (*Tcp) Set added in v1.0.5

func (t *Tcp) Set(userId int64, val any)

func (*Tcp) WQueue

func (t *Tcp) WQueue() <-chan []byte

func (*Tcp) Write

func (t *Tcp) Write(pack []byte) (int, error)

type WebSocket

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

func NewWebSocket

func NewWebSocket(fd uint64, conn net.Conn) *WebSocket

func (*WebSocket) Close

func (t *WebSocket) Close() error

func (*WebSocket) Closed

func (t *WebSocket) Closed() bool

func (*WebSocket) Expired added in v1.0.2

func (t *WebSocket) Expired() bool

func (*WebSocket) FD

func (t *WebSocket) FD() uint64

func (*WebSocket) Get added in v1.0.5

func (t *WebSocket) Get(key int64) (any, bool)

func (*WebSocket) Read

func (t *WebSocket) Read(hLen, bLen, bLenOffset int) ([]byte, error)

func (*WebSocket) RemoteIp added in v0.1.2

func (t *WebSocket) RemoteIp() string

func (*WebSocket) SQueue added in v1.0.6

func (t *WebSocket) SQueue() <-chan bool

func (*WebSocket) Send added in v0.0.2

func (t *WebSocket) Send(pack IPacket) error

func (*WebSocket) SendBytes added in v0.0.5

func (t *WebSocket) SendBytes(buf []byte) error

func (*WebSocket) Set added in v1.0.5

func (t *WebSocket) Set(key int64, val any)

func (*WebSocket) WQueue

func (t *WebSocket) WQueue() <-chan []byte

func (*WebSocket) Write

func (t *WebSocket) Write(pack []byte) (int, error)

Jump to

Keyboard shortcuts

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