Documentation
¶
Index ¶
- func NewSSESession(n *node.Node, w http.ResponseWriter, r *http.Request, info *server.RequestInfo) (*node.Session, error)
- func SSEHandler(n *node.Node, shutdownCtx context.Context, ...) http.Handler
- type Config
- type Connection
- func (c *Connection) Close(code int, reason string)
- func (c *Connection) Context() context.Context
- func (c *Connection) Descriptor() net.Conn
- func (c *Connection) Established()
- func (c *Connection) Read() ([]byte, error)
- func (c *Connection) Write(msg []byte, deadline time.Time) error
- func (c *Connection) WriteBinary(msg []byte, deadline time.Time) error
- type Encoder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewSSESession ¶
Types ¶
type Config ¶
type Config struct { Enabled bool // Path is the URL path to handle long-polling requests Path string // List of allowed origins for CORS requests // We inherit it from the ws.Config AllowedOrigins string }
Long-polling configuration
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func NewConnection ¶
func NewConnection(w http.ResponseWriter) *Connection
NewConnection creates a new long-polling connection wrapper
func (*Connection) Close ¶
func (c *Connection) Close(code int, reason string)
func (*Connection) Context ¶
func (c *Connection) Context() context.Context
func (*Connection) Descriptor ¶
func (c *Connection) Descriptor() net.Conn
func (*Connection) Established ¶
func (c *Connection) Established()
Mark as closed to avoid writing to closed connection
func (*Connection) Read ¶
func (c *Connection) Read() ([]byte, error)
func (*Connection) WriteBinary ¶
func (c *Connection) WriteBinary(msg []byte, deadline time.Time) error
type Encoder ¶
type Encoder struct { // Whether to send only the "message" field of the payload as data or the whole payload UnwrapData bool }
Encoder is responsible for converting messages to SSE format (event:, data:, etc.) NOTE: It's only used to encode messages from server to client.
func (Encoder) EncodeTransmission ¶
Click to show internal directories.
Click to hide internal directories.