websocket

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 5, 2025 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Bind       string `yaml:"bind"`
	Port       uint16 `yaml:"port"`
	URL        *url.URL
	Limitation *Limitation
}

type Limitation

type Limitation struct {
	MaxMessageLength    int32 // todo?.
	MaxSubscriptions    int32
	MaxSubidLength      int32
	MinPowDifficulty    int32
	AuthRequired        bool
	PaymentRequired     bool
	RestrictedWrites    bool
	MaxEventTags        int32
	MaxContentLength    int32
	CreatedAtLowerLimit int64
	CreatedAtUpperLimit int64
}

type Server

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

Server represents a websocket serer which keeps track of client connections and handle them.

func New

func New(cfg Config, h *repository.Handler, m *metrics.Metrics,
	r *redis.Redis, grpc grpcclient.IClient,
) (*Server, error)

func (*Server) ServeHTTP

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

handleWS is WebSocket handler.

func (*Server) Start

func (s *Server) Start() error

Start starts a new server instance.

func (*Server) Stop

func (s *Server) Stop() error

Stop shutdowns the server gracefully.

Jump to

Keyboard shortcuts

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