Documentation ¶
Index ¶
- Constants
- func Handle(fn func(*Client)) func(*ghttp.Request)
- type Client
- func (c *Client) Close()
- func (c *Client) Context() context.Context
- func (c *Client) KeepAlive()
- func (c *Client) OnClose(fn func(*Client))
- func (c *Client) Request() *ghttp.Request
- func (c *Client) Response() *ghttp.Response
- func (c *Client) SendComment(comment ...string)
- func (c *Client) SendEvent(event string, data ...string)
- func (c *Client) SendEventWithId(id, event string, data ...string)
- func (c *Client) SendMessage(data ...string)
- func (c *Client) SendMessageWithId(id string, data ...string)
- func (c *Client) Terminated() bool
Constants ¶
View Source
const ( NoId = "" NoEvent = "" EmptyComment = "" )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client wraps the SSE(Server-Sent Event) ghttp.Request and provides SSE APIs
func (*Client) KeepAlive ¶
func (c *Client) KeepAlive()
KeepAlive keeps the connection alive, if you need to use the client outside the handler
func (*Client) SendComment ¶
SendComment send comment with prefix":"
func (*Client) SendEventWithId ¶
SendEventWithId calls emit(id, event, data...)
func (*Client) SendMessage ¶
SendMessage calls emit(NoId, NoEvent, data...)
func (*Client) SendMessageWithId ¶
SendMessageWithId calls emit(id, NoEvent, data...)
func (*Client) Terminated ¶
Terminated returns true if the connection has been closed
Click to show internal directories.
Click to hide internal directories.