conn

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2022 License: MulanPSL-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Armour

type Armour interface {
}

用于绑定Receiver/Client的用户负载对象

type Connection

type Connection interface {
	Remote() net.Addr

	Owner() ConnectionOwner
	BindOwner(ConnectionOwner)

	Start(*Sender) error
	Close()

	Send(*protocol.Packet) error
	RecvChan() <-chan *protocol.Packet
	Done() <-chan struct{}

	SetConfoundCode([]byte)
	ConfoundCode() []byte
}

Connection面向Receiver的连接抽象接口 对于具体的实现, 要求: 1. Send接口传入的Packet为未编码形态, 需要具体实现中进行编码 2. RecvChan的channel中推入的Packet必须为已解码的形态

type ConnectionOwner

type ConnectionOwner interface {
	OnNetClosed()
}

type FDialConn

type FDialConn func(cfg interface{}, fc FRecvChan) (Connection, error)

type FRecvChan

type FRecvChan func() chan *protocol.Packet

type Listener

type Listener interface {
	Addr() net.Addr
	Accept(fc FRecvChan) (Connection, error)
	Close()
}

type Sender

type Sender struct {
	Sequence uint64
}

发送者. 作为接收者的一个组件, 集中管理发送消息相关的状态维护和工具函数

func NewSender

func NewSender() *Sender

func (*Sender) AssemblePacket

func (s *Sender) AssemblePacket(header *protocol.Header, msg protocol.Message) *protocol.Packet

func (*Sender) NewHeaderAsResponse

func (s *Sender) NewHeaderAsResponse(reqHeader *protocol.Header, ec uint32, em string, protoID uint32) *protocol.Header

func (*Sender) NewHeaderEmpty

func (s *Sender) NewHeaderEmpty() *protocol.Header

func (*Sender) NewHeaderWithMessage

func (s *Sender) NewHeaderWithMessage(msg protocol.Message) *protocol.Header

func (*Sender) NewPacketAsResponse

func (s *Sender) NewPacketAsResponse(reqHeader *protocol.Header, ec uint32, em string, msg protocol.Message) *protocol.Packet

msg可以为nil, 表示空返回

func (*Sender) NewPacketWithMessage

func (s *Sender) NewPacketWithMessage(msg protocol.Message) *protocol.Packet

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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