ws

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MPL-2.0 Imports: 16 Imported by: 0

Documentation

Overview

Package ws implements websocket server and protocol.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	*websocket.Conn
	// contains filtered or unexported fields
}

Conn thread safe wrapper for websocket.Conn.

func (*Conn) WriteProtobuf

func (c *Conn) WriteProtobuf(message protoreflect.ProtoMessage) error

WriteProtobuf writes protobuf message to the websocket.

type Server

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

Server is a websocket server.

func New

func New(ctx context.Context, mux *http.ServeMux) *Server

New creates new websocket server instance and registers routes in the gin engine.

type Session

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

Session keeps the information about client subscriptions and handles data update routing.

func NewSession

func NewSession(ctx context.Context, conn *Conn) *Session

NewSession creates a new session.

func (*Session) Shutdown

func (s *Session) Shutdown()

Shutdown cleans up all related session resources.

type Subscription

type Subscription struct {
	// ID should be an unique subscription id.
	// Message routing is using this ID to sync server and client sides.
	ID string
	// contains filtered or unexported fields
}

Subscription is a reactive list of items that sends updates to the websocket on each state change.

func NewSubscription

func NewSubscription(ctx context.Context, r runtime.Runtime, watch *message.WatchSpec, conn *Conn) (*Subscription, error)

NewSubscription creates new Subscription.

Directories

Path Synopsis
Package proto specifies websocket protocol helpers.
Package proto specifies websocket protocol helpers.

Jump to

Keyboard shortcuts

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