event

package
v1.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package event is a generated GoMock package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AcceptProcess added in v1.5.1

type AcceptProcess interface {
	Accept(session *Session) error
}

AcceptProcess 网络建立连接时执行

type BootClient

type BootClient struct {
	*Event
	// contains filtered or unexported fields
}

func NewBootClient

func NewBootClient() *BootClient

func NewBootClientContext added in v1.4.1

func NewBootClientContext(ctx context.Context) *BootClient

func (*BootClient) CancelFunc added in v1.4.1

func (b *BootClient) CancelFunc()

func (*BootClient) Dial added in v1.5.1

func (b *BootClient) Dial(network string, addr string) (StarterClient, error)

func (*BootClient) DialTcp added in v1.4.1

func (b *BootClient) DialTcp(addr string) (StarterClient, error)

func (*BootClient) DialTcpTimeout added in v1.5.1

func (b *BootClient) DialTcpTimeout(addr string, timeout time.Duration) (StarterClient, error)

func (*BootClient) DialTimeout added in v1.5.1

func (b *BootClient) DialTimeout(network string, addr string, timeout time.Duration) (StarterClient, error)

func (*BootClient) DialUdp added in v1.5.1

func (b *BootClient) DialUdp(addr string) (StarterClient, error)

func (*BootClient) DialUdpTimeout added in v1.5.1

func (b *BootClient) DialUdpTimeout(addr string, timeout time.Duration) (StarterClient, error)

type BootServer

type BootServer struct {
	*Event
	// contains filtered or unexported fields
}

func NewBootServer

func NewBootServer() *BootServer

func NewBootServerContext added in v1.4.1

func NewBootServerContext(ctx context.Context) *BootServer

func (*BootServer) BindAddr added in v1.4.1

func (b *BootServer) BindAddr(network string, addr string) error

BindAddr 绑定监听地址, 如:localhost:8080, 0.0.0.0:8080, :8080, [::1]:0

func (*BootServer) CancelFunc added in v1.4.1

func (b *BootServer) CancelFunc()

func (*BootServer) ListenTcp added in v1.4.1

func (b *BootServer) ListenTcp(addr string) error

ListenTcp 启动监听

func (*BootServer) ListenUdp added in v1.5.1

func (b *BootServer) ListenUdp(addr string) error

func (*BootServer) Starter

func (b *BootServer) Starter() StarterServer

func (*BootServer) Stop added in v1.4.1

func (b *BootServer) Stop() error

type DisconnectProcess added in v1.5.1

type DisconnectProcess interface {
	Disconnect(session *Session) error
}

DisconnectProcess 网络连接断开时执行

type Event

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

func NewEvent

func NewEvent() *Event

func (*Event) ProcessList

func (e *Event) ProcessList() []interface{}

func (*Event) Register

func (e *Event) Register(proc Process)

func (*Event) RegisterPlus added in v1.5.1

func (e *Event) RegisterPlus(proc any) error

func (*Event) UnRegister

func (e *Event) UnRegister(proc Process)

type MockProcess

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

MockProcess is a mock of Process interface.

func NewMockProcess

func NewMockProcess(ctrl *gomock.Controller) *MockProcess

NewMockProcess creates a new mock instance.

func (*MockProcess) Accept

func (m *MockProcess) Accept(session *Session) error

Accept mocks base method.

func (*MockProcess) Active

func (m *MockProcess) Active(session *Session, value any) (any, error)

Active mocks base method.

func (*MockProcess) Disconnect

func (m *MockProcess) Disconnect(session *Session) error

Disconnect mocks base method.

func (*MockProcess) EXPECT

func (m *MockProcess) EXPECT() *MockProcessMockRecorder

EXPECT returns an object that allows the caller to indicate expected use.

type MockProcessMockRecorder

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

MockProcessMockRecorder is the mock recorder for MockProcess.

func (*MockProcessMockRecorder) Accept

func (mr *MockProcessMockRecorder) Accept(session any) *gomock.Call

Accept indicates an expected call of Accept.

func (*MockProcessMockRecorder) Active

func (mr *MockProcessMockRecorder) Active(session, value any) *gomock.Call

Active indicates an expected call of Active.

func (*MockProcessMockRecorder) Disconnect

func (mr *MockProcessMockRecorder) Disconnect(session any) *gomock.Call

Disconnect indicates an expected call of Disconnect.

type Process

type Process interface {
	Active(session *Session, value any) (any, error)
}

Process 有请求数据时执行

type Session

type Session struct {
	Socket *socket.Socket
	// contains filtered or unexported fields
}

Session 会话对象, 每个连接都有唯一会话

func NewSession

func NewSession(socket *socket.Socket) *Session

func NewSessionContext added in v1.4.1

func NewSessionContext(socket *socket.Socket, ctx context.Context) *Session

func (*Session) CancelFunc added in v1.4.1

func (s *Session) CancelFunc()

func (*Session) Close

func (s *Session) Close() error

func (*Session) Ctx added in v1.4.1

func (s *Session) Ctx() context.Context

func (*Session) GetAttr

func (s *Session) GetAttr(key string) any

func (*Session) SetAttr

func (s *Session) SetAttr(key string, value any)

func (*Session) SetState

func (s *Session) SetState(state SessionState)

func (*Session) State

func (s *Session) State() SessionState

type SessionState

type SessionState int

SessionState 会话状态

const (
	Accept     SessionState = iota // 新建连接
	Active                         // 活动连接
	Disconnect                     // 断开连接
)

type StarterClient

type StarterClient interface {
	Dial(addr string) (*Session, error)
	DialTimeout(addr string, timeout time.Duration) (*Session, error)
	Session() (session *Session)

	Request(body any) (any, error)
	Close() error
	// contains filtered or unexported methods
}

StarterClient 客户端启动器接口

type StarterServer

type StarterServer interface {
	Listen() error
	Listener() net.Listener
	Close() error
}

StarterServer 服务端启动器接口

Jump to

Keyboard shortcuts

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