socketapi

package
v1.14.3 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2025 License: Unlicense Imports: 42 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultChallengeHRP    = "nchal"
	DefaultChallengeLength = 16
)
View Source
const (
	DefaultWriteWait      = 10 * time.Second
	DefaultPongWait       = 60 * time.Second
	DefaultPingWait       = DefaultPongWait / 2
	DefaultMaxMessageSize = 1 * units.Mb
)
View Source
const Type = "socketapi"

Variables

View Source
var (
	NIP20prefixmatcher = regexp.MustCompile(`^\w+: `)
)
View Source
var Upgrader = websocket.Upgrader{ReadBufferSize: 1024, WriteBufferSize: 1024,
	CheckOrigin: func(r *http.Request) bool {
		return true
	}}

Functions

func GetListener added in v1.14.2

func GetListener(conn *websocket.Conn, req *http.Request) (w *ws.Listener)

GetListener generates a new ws.Listener with a new challenge for a subscriber.

Types

type A

type A struct {
	Ctx context.T
	*ws.Listener
	interfaces.Server
}

func (*A) HandleAuth

func (a *A) HandleAuth(req []byte,
	srv interfaces.Server) (msg []byte)

func (*A) HandleClose

func (a *A) HandleClose(req []byte,
	srv interfaces.Server) (note []byte)

func (*A) HandleEvent

func (a *A) HandleEvent(c context.T, req []byte, srv interfaces.Server) (msg []byte)

func (*A) HandleMessage

func (a *A) HandleMessage(msg []byte)

func (*A) HandleReq

func (a *A) HandleReq(
	c context.T, req []byte,
	skipEventFunc options.SkipEventFunc, srv interfaces.Server) (r []byte)

func (*A) Pinger

func (a *A) Pinger(ctx context.T, ticker *time.Ticker, cancel context.F, s interfaces.Server)

func (*A) Serve

func (a *A) Serve(w http.ResponseWriter, r *http.Request, s interfaces.Server)

type Close added in v1.14.3

type Close struct {
	*ws.Listener
	Id string
}

type Map added in v1.14.3

type Map map[*ws.Listener]map[string]*filters.T

Map is a map of filters associated with a collection of ws.Listener connections.

type S added in v1.14.3

type S struct {
	// Mx is the mutex for the Map.
	Mx sync.Mutex
	// Map is the map of subscribers and subscriptions from the websocket api.
	Map
}

func New added in v1.14.3

func New() *S

func (*S) Deliver added in v1.14.3

func (p *S) Deliver(authRequired, publicReadable bool, ev *event.T)

func (*S) Receive added in v1.14.3

func (p *S) Receive(msg publisher.Message)

func (*S) Type added in v1.14.3

func (p *S) Type() string

type W added in v1.14.3

type W struct {
	*ws.Listener
	// If Cancel is true, this is a close command.
	Cancel bool
	// Id is the subscription Id. If Cancel is true, cancel the named subscription, otherwise,
	// cancel the publisher for the socket.
	Id       string
	Receiver event.C
	Filters  *filters.T
}

func (*W) Type added in v1.14.3

func (w *W) Type() string

Jump to

Keyboard shortcuts

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