{"modulePath":"github.com/hookdeck/hookdeck-cli","version":"v1.9.1","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package websocket\n\n## Variables\n\n```go\nvar ErrUnknownID error = errors.New(unknownIDMessage)\n```\nErrUnknownID can occur when the websocket session is expired or invalid\n\n## Types\n\n```go\ntype Attempt struct {\n\tEvent string      `json:\"type\"`\n\tBody  AttemptBody `json:\"body\"`\n}\n```\n\n```go\ntype AttemptBody struct {\n\tPath         string         `json:\"cli_path\"`\n\tEventID      string         `json:\"event_id\"`\n\tAttemptId    string         `json:\"attempt_id\"`\n\tConnectionId string         `json:\"webhook_id\"`\n\tRequest      AttemptRequest `json:\"request\"`\n}\n```\n\n```go\ntype AttemptRequest struct {\n\tMethod     string          `json:\"method\"`\n\tTimeout    int64           `json:\"timeout\"`\n\tDataString string          `json:\"data_string\"`\n\tHeaders    json.RawMessage `json:\"headers\"`\n}\n```\n\n```go\ntype AttemptResponse struct {\n\tEvent string              `json:\"event\"`\n\tBody  AttemptResponseBody `json:\"body\"`\n}\n```\n\n```go\ntype AttemptResponseBody struct {\n\tAttemptId string `json:\"attempt_id\"`\n\tCLIPath   string `json:\"cli_path\"`\n\tStatus    int    `json:\"status\"`\n\tData      string `json:\"data\"`\n}\n```\n\n```go\ntype Client struct {\n\t// URL the client connects to\n\tURL string\n\n\tCLIKey string\n\n\tTeamID string\n\n\t// ID sent by the client in the `Websocket-Id` header when connecting\n\tWebSocketID string\n\n\tNotifyExpired chan struct{}\n\t// contains filtered or unexported fields\n}\n```\nClient is the client used to receive webhook requests from Hookdeck and send back webhook responses from the local endpoint to Hookdeck.\n\n```go\nfunc NewClient(url string, webSocketID string, CLIKey string, teamID string, cfg *Config) *Client\n```\nNewClient returns a new Client.\n\n```go\nfunc (c *Client) Connected() \u003c-chan struct{}\n```\nConnected returns a channel that's closed when the client has finished establishing the websocket connection.\n\n```go\nfunc (c *Client) ConnectionLost()\n```\nConnectionLost sends NotifyExpired\n\n```go\nfunc (c *Client) Run(ctx context.Context)\n```\nRun starts listening for incoming webhook requests from Hookdeck.\n\n```go\nfunc (c *Client) SendMessage(msg *OutgoingMessage)\n```\nSendMessage sends a message to Hookdeck through the websocket.\n\n```go\nfunc (c *Client) Stop()\n```\nStop stops listening for incoming webhook events.\n\n```go\ntype Config struct {\n\tConnectAttemptWait time.Duration\n\n\tDialer *ws.Dialer\n\n\tLog *log.Logger\n\n\t// Force use of unencrypted ws:// protocol instead of wss://\n\tNoWSS bool\n\n\tPingPeriod time.Duration\n\n\tPongWait time.Duration\n\n\tWriteWait time.Duration\n\n\tEventHandler EventHandler\n}\n```\nConfig contains the optional configuration parameters of a Client.\n\n```go\ntype ConnectionMessage struct {\n\tEvent string                `json:\"event\"`\n\tBody  ConnectionMessageBody `json:\"body\"`\n}\n```\n\n```go\ntype ConnectionMessageBody struct {\n\tSourceId      string   `json:\"source_id\"`\n\tConnectionIds []string `json:\"webhook_ids\"`\n}\n```\n\n```go\ntype ErrorAttemptBody struct {\n\tAttemptId string `json:\"attempt_id\"`\n\tError     bool   `json:\"error\"`\n}\n```\n\n```go\ntype ErrorAttemptResponse struct {\n\tEvent string           `json:\"event\"`\n\tBody  ErrorAttemptBody `json:\"body\"`\n}\n```\n\n```go\ntype EventHandler interface {\n\tProcessEvent(IncomingMessage)\n}\n```\nEventHandler handles an event.\n\n```go\ntype EventHandlerFunc func(IncomingMessage)\n```\nEventHandlerFunc is an adapter to allow the use of ordinary functions as event handlers. If f is a function with the appropriate signature, EventHandlerFunc(f) is a EventHandler that calls f.\n\n```go\nfunc (f EventHandlerFunc) ProcessEvent(msg IncomingMessage)\n```\nProcessEvent calls f(msg).\n\n```go\ntype IncomingMessage struct {\n\t*Attempt\n}\n```\nIncomingMessage represents any incoming message sent by Hookdeck.\n\n```go\nfunc (m *IncomingMessage) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON deserializes incoming messages sent by Hookdeck into the appropriate structure.\n\n```go\ntype OutgoingMessage struct {\n\t*ErrorAttemptResponse\n\t*AttemptResponse\n\t*ConnectionMessage\n}\n```\nOutgoingMessage represents any outgoing message sent to Hookdeck.\n\n```go\nfunc (m OutgoingMessage) MarshalJSON() ([]byte, error)\n```\nMarshalJSON serializes outgoing messages sent to Hookdeck.\n\n","path":"github.com/hookdeck/hookdeck-cli/pkg/websocket","name":"websocket","synopsis":"","isRedistributable":true}
