connection

package
v0.0.0-...-edd3e93 Latest Latest
Warning

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

Go to latest
Published: Jan 19, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RequestAuth

func RequestAuth(conn net.Conn, identity protocol.Identity, pwd string) (*protocol.Procotol, error)

RequestAuth 请求认证

func ResponseAuth

func ResponseAuth(conn net.Conn, identity protocol.Identity, pwd string) (*protocol.Procotol, error)

ResponseAuth 响应认证

Types

type CommandHandler

type CommandHandler func(proto *protocol.Procotol, conn Conn)

type Conn

type Conn interface {
	// 认证连接
	Auth(pwd string) error
	// 启动心跳
	WithHeart(itv int)
	// 注销连接
	Unregister() error

	// 接收协议包
	Recv() (*protocol.Procotol, error)
	// 发送协议包
	Send(cmd protocol.Command, data any) error

	// 检查连接是否关闭
	IsClosed() bool
	// 获取连接的元数据
	GetMetadata() *metadata
	// 获取最后发送的数据包
	GetLastSendPacket() *protocol.Procotol
	// 获取最后接收的数据包
	GetLastRecvPacket() *protocol.Procotol
}

type GatewayConn

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

func NewGatewayConn

func NewGatewayConn(conn net.Conn, heartbeatInterval int) *GatewayConn

func (GatewayConn) Auth

func (own GatewayConn) Auth(pwd string) (err error)

func (GatewayConn) GetLastRecvPacket

func (own GatewayConn) GetLastRecvPacket() *protocol.Procotol

func (GatewayConn) GetLastSendPacket

func (own GatewayConn) GetLastSendPacket() *protocol.Procotol

func (GatewayConn) GetMetadata

func (own GatewayConn) GetMetadata() *metadata

func (GatewayConn) IsClosed

func (own GatewayConn) IsClosed() bool

func (GatewayConn) Recv

func (own GatewayConn) Recv() (*protocol.Procotol, error)

func (GatewayConn) Send

func (own GatewayConn) Send(cmd protocol.Command, data any) error

func (GatewayConn) Unregister

func (own GatewayConn) Unregister() error

func (GatewayConn) WithHeart

func (own GatewayConn) WithHeart(itv int)

type InstanceConn

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

func NewInstanceConn

func NewInstanceConn(conn net.Conn, heartbeatInterval int) *InstanceConn

func (InstanceConn) Auth

func (own InstanceConn) Auth(pwd string) (err error)

func (InstanceConn) GetLastRecvPacket

func (own InstanceConn) GetLastRecvPacket() *protocol.Procotol

func (InstanceConn) GetLastSendPacket

func (own InstanceConn) GetLastSendPacket() *protocol.Procotol

func (InstanceConn) GetMetadata

func (own InstanceConn) GetMetadata() *metadata

func (InstanceConn) IsClosed

func (own InstanceConn) IsClosed() bool

func (InstanceConn) Recv

func (own InstanceConn) Recv() (*protocol.Procotol, error)

func (*InstanceConn) Register

func (own *InstanceConn) Register(ins *model.Instance) error

func (InstanceConn) Send

func (own InstanceConn) Send(cmd protocol.Command, data any) error

func (InstanceConn) Unregister

func (own InstanceConn) Unregister() error

func (InstanceConn) WithHeart

func (own InstanceConn) WithHeart(itv int)

type RegistrarConn

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

func NewRegistrarConn

func NewRegistrarConn(conn net.Conn, heartbeatInterval int) *RegistrarConn

func (RegistrarConn) Auth

func (own RegistrarConn) Auth(pwd string) (err error)

func (RegistrarConn) GetLastRecvPacket

func (own RegistrarConn) GetLastRecvPacket() *protocol.Procotol

func (RegistrarConn) GetLastSendPacket

func (own RegistrarConn) GetLastSendPacket() *protocol.Procotol

func (RegistrarConn) GetMetadata

func (own RegistrarConn) GetMetadata() *metadata

func (RegistrarConn) IsClosed

func (own RegistrarConn) IsClosed() bool

func (RegistrarConn) Recv

func (own RegistrarConn) Recv() (*protocol.Procotol, error)

func (RegistrarConn) Send

func (own RegistrarConn) Send(cmd protocol.Command, data any) error

func (RegistrarConn) Unregister

func (own RegistrarConn) Unregister() error

func (RegistrarConn) WithHeart

func (own RegistrarConn) WithHeart(itv int)

Jump to

Keyboard shortcuts

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