Documentation ¶
Overview ¶
Package sseclient implement HTTP client for Server-Sent Events (SSE).
Notes on implementation ¶
The SSE specification have inconsistent state when dispatching empty data. In the "9.2.6 Interpreting an event stream", if the data buffer is empty it would return; but in the third example it can dispatch an empty string. In this implement we ignore an empty string in server and client.
References,
Index ¶
Constants ¶
View Source
const ( // EventTypeOpen is set when connection succesfully established. // The passed [Event.Data] is empty. EventTypeOpen = `open` // EventTypeMessage is set when client received message from server, // possibly with new ID. EventTypeMessage = `message` EventTypeError = `error` )
List of system event type.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { C <-chan Event // Endpoint define the HTTP server URL to connect. Endpoint string // LastEventID define the last event ID to be sent during handshake. // Once the handshake success, this field will be reset and may set // with next ID from server. // This field is optional. LastEventID string // Timeout define the read and write timeout when reading and // writing from/to server. // This field is optional default to 10 seconds. Timeout time.Duration // Retry define how long, in milliseconds, the client should wait // before reconnecting back to server after disconnect. // Zero or negative value disable it. // // This field is optional, default to 0 (not retrying). Retry time.Duration // Insecure allow connect to HTTPS endpoint with invalid // certificate. Insecure bool // contains filtered or unexported fields }
Client for SSE. Once the Client filled, user need only to call Connect to start receiving message from channel C.
Click to show internal directories.
Click to hide internal directories.