ws

package
v0.0.0-...-78a506e Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Command

type Command[RequestT any, ReplyT any] struct {
	CommandMeta
	Request RequestT `json:"request"`
	// contains filtered or unexported fields
}

func (Command[RequestT, ReplyT]) Err

func (c Command[RequestT, ReplyT]) Err(format string, args ...interface{}) error

func (Command[RequestT, ReplyT]) FromRaw

func (c Command[RequestT, ReplyT]) FromRaw(r RawCommand) (Errable, error)

func (Command[RequestT, ReplyT]) OK

func (c Command[RequestT, ReplyT]) OK(reply ReplyT) error

type CommandDecoder

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

func (*CommandDecoder) Decode

func (c *CommandDecoder) Decode() (Errable, error)

type CommandMeta

type CommandMeta struct {
	ID      string `json:"id"`
	Command string `json:"command"`
}

type CommandPalette

type CommandPalette map[string]FromRawable

type Conn

type Conn struct {
	CommandDecoder
	// contains filtered or unexported fields
}

func NewConn

func NewConn(w http.ResponseWriter, r *http.Request, palette CommandPalette) (*Conn, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) RecvRaw

func (c *Conn) RecvRaw(obj interface{}) error

func (*Conn) SendMessage

func (c *Conn) SendMessage(m Message) error

func (*Conn) SendRaw

func (c *Conn) SendRaw(obj interface{}) error

type Errable

type Errable interface {
	Err(format string, args ...interface{}) error
}

type FromRawable

type FromRawable interface {
	FromRaw(r RawCommand) (Errable, error)
}

type Message

type Message interface {
	Type() string
}

type RawCommand

type RawCommand = Command[json.RawMessage, interface{}]

type Response

type Response[ResponseT any] struct {
	CommandMeta
	OK       bool      `json:"ok"`
	Error    string    `json:"error,omitempty"`
	Response ResponseT `json:"response,omitempty"`
}

Jump to

Keyboard shortcuts

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