ws

package
v1.8.5 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func HandleFunc

func HandleFunc(msgType string, handler WSHandler)

func Init

func Init()

Types

type Message

type Message struct {
	Type  string `json:"type"`
	Value any    `json:"value,omitempty"`
}

Message - struct for data exchange in Web API

func (*Message) GetString

func (m *Message) GetString(key string) string

func (*Message) String

func (m *Message) String() string

type Transport

type Transport struct {
	Request *http.Request
	// contains filtered or unexported fields
}

func (*Transport) Close

func (t *Transport) Close()

func (*Transport) OnChange

func (t *Transport) OnChange(f func())

func (*Transport) OnClose

func (t *Transport) OnClose(f func())

func (*Transport) OnWrite

func (t *Transport) OnWrite(f func(msg any) error)

func (*Transport) WithContext

func (t *Transport) WithContext(f func(ctx map[any]any))

WithContext - run function with Context variable

func (*Transport) Write

func (t *Transport) Write(msg any)

func (*Transport) Writer added in v1.7.0

func (t *Transport) Writer() io.Writer

type WSHandler

type WSHandler func(tr *Transport, msg *Message) error

Jump to

Keyboard shortcuts

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