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, data string)
- func (c *Client) SendEventWithId(event, data, id string)
- func (c *Client) SendMessage(data string)
- func (c *Client) SendMessageWithId(data, id string)
- func (c *Client) Terminated() bool
Constants ¶
View Source
const ( NoEvent = "" NoId = "" 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("event", "data", "id")
func (*Client) SendMessage ¶
SendMessage calls emit(noEvent, "data", noId)
func (*Client) SendMessageWithId ¶
SendMessageWithId calls emit(noEvent, "data", "id")
func (*Client) Terminated ¶
Terminated returns true if the connection has been closed
Click to show internal directories.
Click to hide internal directories.