protocol

package
v0.5.5 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2023 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientInterceptor

type ClientInterceptor interface {
	OnConnected(ctx context.Context, c base.Conn)
	OnClosing(c base.Conn, reason int)
	OnClosed(c base.Conn, reason int)

	OnError(ctx context.Context, c base.Conn, err error)

	// OnReading handles reading event for tcp mode
	OnReading(ctx context.Context, c base.Conn, data []byte) (processed bool, err error)
	// OnWriting handles writing event for tcp mode
	// You may override the internal writing action with processed = true and
	// write data yourself. for instance:
	//     processed = true
	//     c.RawWrite(data)
	OnWriting(ctx context.Context, c base.Conn, data []byte) (processed bool, err error)

	// OnUDPReading is special hook if in udp mode
	OnUDPReading(ctx context.Context, c log.Logger, packet *base.UdpPacket) (processed bool, err error)
	// OnUDPWriting is special hook if in udp mode
	OnUDPWriting(ctx context.Context, c log.Logger, packet *base.UdpPacket) (processed bool, err error)
}

type ClientInterceptorHolder

type ClientInterceptorHolder interface {
	ProtocolInterceptor() ClientInterceptor
}

type Interceptor

type Interceptor interface {
	OnListened(baseCtx context.Context, addr string)
	OnServerReady(ctx context.Context, c log.Logger) // ctx.Value["conn"] -> base.Conn
	OnServerClosed(serverAsLogger log.Logger)        // todo adding ctx param

	ClientInterceptor
}

type InterceptorHolder

type InterceptorHolder interface {
	ProtocolInterceptor() Interceptor
}

Jump to

Keyboard shortcuts

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