event

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2024 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 ActivateHandle

type ActivateHandle interface {
	Activate(context *HandleContext) bool
}

ActivateHandle 连接建立时执行

type Bootstrap

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

func NewBootstrap

func NewBootstrap() *Bootstrap

func (*Bootstrap) AddHandler

func (p *Bootstrap) AddHandler(handler any) *Bootstrap

func (*Bootstrap) Bind

func (p *Bootstrap) Bind() *Session

func (*Bootstrap) Connect

func (p *Bootstrap) Connect() (*Session, error)

func (*Bootstrap) TcpClient

func (p *Bootstrap) TcpClient(addr string) *Bootstrap

func (*Bootstrap) TcpServer

func (p *Bootstrap) TcpServer(addr string) *Bootstrap

TcpServer 设置tcp服务器的地址和端口, 如 localhost:8080、127.0.0.1:8080、0.0.0.0:8080、:8080

type Direction

type Direction int

type DisconnectHandle

type DisconnectHandle interface {
	Disconnect(context *HandleContext) bool
}

DisconnectHandle 连接断开时执行

type HandleContext

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

func NewContext

func NewContext(session *Session) *HandleContext

func (HandleContext) Direction

func (h HandleContext) Direction() Direction

func (HandleContext) Session

func (h HandleContext) Session() *Session

type InputHandle

type InputHandle[T any] interface {
	Input(context *HandleContext, data T) (any, bool)
}

type Loop

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

func NewEventLoop

func NewEventLoop(pipeLine *PipeLine) *Loop

func (*Loop) Bind

func (p *Loop) Bind(server socket.Server) *Session

func (*Loop) Connect

func (p *Loop) Connect(client socket.Client) (*Session, error)

type OutputHandle

type OutputHandle[T any] interface {
	Output(context *HandleContext, data T) (any, bool)
}

OutputHandle 数据出站, 发送数据时执行

type PipeLine

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

func NewPipeLine

func NewPipeLine() *PipeLine

func (*PipeLine) AddHandler

func (p *PipeLine) AddHandler(handler any) error

func (*PipeLine) InsertHandler

func (p *PipeLine) InsertHandler(index int, handler any) (err error)

type Session

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

func NewClientSession added in v1.2.0

func NewClientSession(sock *socket.Socket, client socket.Client, pipeline *PipeLine) *Session

func NewServerSession added in v1.2.0

func NewServerSession(sock *socket.Socket, server socket.Server, pipeline *PipeLine) *Session

func (*Session) Close

func (p *Session) Close() error

func (*Session) Flush

func (p *Session) Flush()

func (*Session) Id

func (p *Session) Id() string

func (*Session) InputContext

func (p *Session) InputContext() *HandleContext

func (*Session) OutputContext

func (p *Session) OutputContext() *HandleContext

func (*Session) PipeLine

func (p *Session) PipeLine() *PipeLine

func (*Session) SessionType

func (p *Session) SessionType() SessionType

func (*Session) Sock

func (p *Session) Sock() *socket.Socket

func (*Session) State

func (p *Session) State() SessionState

func (*Session) Wait

func (p *Session) Wait()

func (*Session) Write

func (p *Session) Write(data any)

func (*Session) WriteAndFlush

func (p *Session) WriteAndFlush(data any)

func (*Session) WriteSocket added in v1.2.0

func (p *Session) WriteSocket(data any) (n int, err error)

type SessionState

type SessionState int
const (
	Accept SessionState = iota
	Active
	Disconnect
)

type SessionType

type SessionType int
const (
	ClientSession SessionType = iota
	ServerSession
	ListenSession
)

Jump to

Keyboard shortcuts

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