v2

package module
v2.15.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 1

Documentation

Overview

Package ws implements the Websocket protocol binding

Index

Constants

View Source
const JsonSubprotocol = "cloudevents.json"

Variables

View Source
var SupportedSubprotocols = []string{JsonSubprotocol}

Functions

func WithCloseReason

func WithCloseReason(ctx context.Context, code websocket.StatusCode, reason string) context.Context

Types

type ClientProtocol

type ClientProtocol struct {
	// contains filtered or unexported fields
}

ClientProtocol implements protocol.Receiver, protocol.Sender and protocol.Closer. Note: when you use client.StartReceiver with this protocol, you can use just one goroutine to poll this protocol, because the protocol itself cannot handle multiple received messages at same time (WS has no multiplexing!)

func Dial

Dial wraps websocket.Dial and creates the ClientProtocol.

func NewClientProtocol

func NewClientProtocol(c *websocket.Conn) (*ClientProtocol, error)

NewClientProtocol wraps a websocket.Conn in a type that implements protocol.Receiver, protocol.Sender and protocol.Closer. Look at ClientProtocol for more details.

func (*ClientProtocol) Close

func (c *ClientProtocol) Close(ctx context.Context) error

func (*ClientProtocol) Receive

func (c *ClientProtocol) Receive(ctx context.Context) (binding.Message, error)

func (*ClientProtocol) Send

func (c *ClientProtocol) Send(ctx context.Context, m binding.Message, transformers ...binding.Transformer) error

func (*ClientProtocol) UnsafeReceive

func (c *ClientProtocol) UnsafeReceive(ctx context.Context) (binding.Message, error)

UnsafeReceive is like Receive, except it doesn't guard from multiple invocations from different goroutines.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL