websocket

package
v0.0.0-...-80248e1 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	IHandler xnetcommon.IHandler
	IRemote  xnetcommon.IRemote
}

Client 客户端

func NewClient

func NewClient(handler xnetcommon.IHandler) *Client

func (*Client) Connect

func (p *Client) Connect(ctx context.Context, opts ...*ConnectOptions) error

Connect 连接

type ConnectOptions

type ConnectOptions struct {
	xnetcommon.ConnOptions
	// contains filtered or unexported fields
}

func NewConnectOptions

func NewConnectOptions() *ConnectOptions

func (*ConnectOptions) WithAddress

func (p *ConnectOptions) WithAddress(address string) *ConnectOptions

func (*ConnectOptions) WithIOut

func (p *ConnectOptions) WithIOut(iOut xcontrol.IOut) *ConnectOptions

func (*ConnectOptions) WithSendChanCapacity

func (p *ConnectOptions) WithSendChanCapacity(sendChanCapacity uint32) *ConnectOptions

type Remote

type Remote struct {
	Conn *websocket.Conn // 连接
	*xnetcommon.DefaultRemote
}

Remote 远端

func NewRemote

func NewRemote(Conn *websocket.Conn, sendChan chan any) *Remote

func (*Remote) GetIP

func (p *Remote) GetIP() string

GetIP 获取IP地址

func (*Remote) IsConnect

func (p *Remote) IsConnect() bool

IsConnect 是否连接

func (*Remote) Send

func (p *Remote) Send(packet xpacket.IPacket) error

Send 发送数据

[⚠️]必须在 总线/actor 中调用
参数:
	packet: 未序列化的包. [NOTE]该数据会被引用,使用层不可写

func (*Remote) Start

func (p *Remote) Start(connOptions *xnetcommon.ConnOptions, iout xcontrol.IOut, handler xnetcommon.IHandler)

func (*Remote) Stop

func (p *Remote) Stop()

type Server

type Server struct {
	IHandler xnetcommon.IHandler
	// contains filtered or unexported fields
}

Server 服务端

func NewServer

func NewServer(handler xnetcommon.IHandler) *Server

NewServer 新建服务

func (*Server) Start

func (p *Server) Start(ctx context.Context, opts ...*ServerOptions) error

Start 运行服务

func (*Server) Stop

func (p *Server) Stop()

Stop 停止 WebSocket 服务器

type ServerOptions

type ServerOptions struct {
	xnetcommon.ConnOptions
	xnetcommon.PacketLimitOptions
	// contains filtered or unexported fields
}

func NewServerOptions

func NewServerOptions() *ServerOptions

NewServerOptions 新的ServerOptions

func (*ServerOptions) WithIOut

func (p *ServerOptions) WithIOut(iOut xcontrol.IOut) *ServerOptions

func (*ServerOptions) WithListenAddress

func (p *ServerOptions) WithListenAddress(listenAddress string) *ServerOptions

func (*ServerOptions) WithPattern

func (p *ServerOptions) WithPattern(pattern string) *ServerOptions

func (*ServerOptions) WithSendChanCapacity

func (p *ServerOptions) WithSendChanCapacity(sendChanCapacity uint32) *ServerOptions

Jump to

Keyboard shortcuts

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