wsmapper

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 29, 2020 License: MIT Imports: 15 Imported by: 0

README

goWsMapper

WebSocket (gorilla-based) client with JSON routing

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GzipDecode

func GzipDecode(in []byte) ([]byte, error)

Types

type Client

type Client struct {
	sync.RWMutex
	// contains filtered or unexported fields
}

func Dial

func Dial(ctx context.Context, url string, mapper TypeMapper, errorHandler func(WsError)) (*Client, error)

func (*Client) Send

func (c *Client) Send(data []byte) error

func (*Client) Stop

func (c *Client) Stop()

type TypeMapper

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

func NewTypeMapper

func NewTypeMapper() *TypeMapper

func NewTypeMapperWithDefault

func NewTypeMapperWithDefault(defaultHandler func([]byte)) *TypeMapper

func (*TypeMapper) RegisterProcessors

func (m *TypeMapper) RegisterProcessors(matchers ...*TypeMatcher)

func (*TypeMapper) Route

func (m *TypeMapper) Route(JSON []byte) error

type TypeMatcher

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

func NewTypeMatcher

func NewTypeMatcher(callback, validator interface{}) *TypeMatcher

type WsError

type WsError struct {
	Code         WsErrorCode
	Msg          string
	WrappedError error
}

func (*WsError) Error

func (err *WsError) Error() string

type WsErrorCode

type WsErrorCode int
const (
	NormalShutdown WsErrorCode = 0 + iota
	Disconnect
	Unknown
)

Jump to

Keyboard shortcuts

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