client

package
v1.23.2 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: MIT Imports: 5 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 {
	ID string // 客户端唯一标识
	// contains filtered or unexported fields
}

Client 表示一个SSE客户端连接

func New

func New(ctx context.Context, id string, request *http.Request, writer http.ResponseWriter) *Client

func (*Client) Close

func (c *Client) Close()

func (*Client) GetEvents

func (c *Client) GetEvents() []string

GetEvents 获取所有订阅的事件列表

func (*Client) IsClosed

func (c *Client) IsClosed() bool

func (*Client) IsSubscribed

func (c *Client) IsSubscribed(event string) bool

IsSubscribed 检查是否订阅了指定事件

func (*Client) Run

func (c *Client) Run(heartbeatInterval time.Duration)

func (*Client) SendMessage

func (c *Client) SendMessage(msg string) error

func (*Client) Subscribe

func (c *Client) Subscribe(events ...string)

Subscribe 订阅指定事件

func (*Client) Unsubscribe

func (c *Client) Unsubscribe(events ...string)

Unsubscribe 取消订阅指定事件

Jump to

Keyboard shortcuts

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