uniws

package
v6.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2025 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultWebsocketPingInterval     = 25 * time.Second
	DefaultWebsocketWriteTimeout     = 1 * time.Second
	DefaultWebsocketMessageSizeLimit = 65536 // 64KB
)

Defaults.

Variables

This section is empty.

Functions

func NewCancelContext

func NewCancelContext(ctx context.Context, ch <-chan struct{}) context.Context

NewCancelContext returns a wrapper context around original context that will be canceled on channel close.

Types

type Config

type Config = configtypes.UniWebSocket

type ConnectRequest

type ConnectRequest struct {
	Token   string                       `json:"token,omitempty"`
	Data    json.RawMessage              `json:"data,omitempty"`
	Subs    map[string]*SubscribeRequest `json:"subs,omitempty"`
	Name    string                       `json:"name,omitempty"`
	Version string                       `json:"version,omitempty"`
}

type Handler

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

Handler handles WebSocket client connections. Usually WebSocket protocol is a bidirectional connection between a client and a server for low-latency communication. Here we utilize only one direction - giving users an additional option for unidirectional transport.

func NewHandler

func NewHandler(
	n *centrifuge.Node, c Config, CheckOrigin func(r *http.Request) bool, pingPong centrifuge.PingPongConfig,
) *Handler

NewHandler creates new Handler.

func (*Handler) ServeHTTP

func (s *Handler) ServeHTTP(rw http.ResponseWriter, r *http.Request)

type SubscribeRequest

type SubscribeRequest struct {
	Recover bool   `json:"recover,omitempty"`
	Epoch   string `json:"epoch,omitempty"`
	Offset  uint64 `json:"offset,omitempty"`
}

Jump to

Keyboard shortcuts

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