signalr

package
v0.2.8 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2022 License: MIT Imports: 14 Imported by: 1

Documentation

Index

Constants

View Source
const (
	JSONSeparator = 0x1e
)

Separator

Variables

View Source
var (
	ErrUnknownMessageType = errors.New("unknown message type")
	ErrMessageParsing     = errors.New("can't parse message")
	ErrEmptyResponse      = errors.New("empty response from server")
	ErrHandshake          = errors.New("handshake error")
	ErrInvalidStatusCode  = errors.New("invalid status code")
	ErrNegotiate          = errors.New("negotiate error")
	ErrInvalidScheme      = errors.New("invalid URL scheme. Expected https or http. Got")
	ErrConnectionClose    = errors.New("connection is closed")
	ErrTimeout            = errors.New("connection timeout")
)

Functions

func SplitJSON

func SplitJSON(data []byte, atEOF bool) (advance int, token []byte, err error)

SplitJSON -

Types

type AvailableTransport

type AvailableTransport struct {
	Transport       string   `json:"transport"`
	TransferFormats []string `json:"transferFormats"`
}

AvailableTransport -

type CancelInvocation

type CancelInvocation Message

CancelInvocation - a `CancelInvocation` message

type CloseMessage

type CloseMessage struct {
	Type
	Error          string `json:"string,omitempty"`
	AllowReconnect bool   `json:"allowReconnect,omitempty"`
}

CloseMessage - a `CloseMessage` message

type Completion

type Completion struct {
	Message
	Result uint64 `json:"result,omitempty"`
	Error  string `json:"string,omitempty"`
}

Completion - a `Completion` message

type Encoding

type Encoding interface {
	Decode(data []byte) (interface{}, error)
	Encode(msg interface{}) ([]byte, error)
}

Encoding -

type Error

type Error struct {
	Error string `json:"string,omitempty"`
}

Error -

type HandshakeRequest

type HandshakeRequest struct {
	Protocol string `json:"protocol"`
	Version  int    `json:"version"`
}

HandshakeRequest -

type Hub

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

Hub -

func NewHub

func NewHub(address, connectionToken string) (*Hub, error)

NewHub -

func (*Hub) Close

func (hub *Hub) Close() error

Close -

func (*Hub) Connect

func (hub *Hub) Connect() error

Connect -

func (*Hub) Send

func (hub *Hub) Send(msg interface{}) error

Send - send message

type Invocation

type Invocation struct {
	Message
	Target    string               `json:"target"`
	Arguments []stdJSON.RawMessage `json:"arguments"`
	StreamsID []string             `json:"streamIds,omitempty"`
}

Invocation - a `Invocation` message

func NewInvocation

func NewInvocation(id, target string, args ...interface{}) Invocation

NewInvocation -

type JSONEncoding

type JSONEncoding struct {
}

JSONEncoding -

func NewJSONEncoding

func NewJSONEncoding() *JSONEncoding

NewJSONEncoding -

func (*JSONEncoding) Decode

func (e *JSONEncoding) Decode(data []byte) (interface{}, error)

Decode -

func (*JSONEncoding) Encode

func (e *JSONEncoding) Encode(msg interface{}) ([]byte, error)

Encode -

type JSONReader added in v0.1.1

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

JSONReader -

func NewJSONReader added in v0.1.1

func NewJSONReader(r io.Reader) *JSONReader

NewJSONReader -

func (*JSONReader) Bytes added in v0.1.1

func (r *JSONReader) Bytes() ([]byte, error)

Bytes -

func (*JSONReader) Scan added in v0.1.1

func (r *JSONReader) Scan() error

Scan -

type Message

type Message struct {
	Type
	ID      string            `json:"invocationId"`
	Headers map[string]string `json:"headers,omitempty"`
}

Message -

type MessageType

type MessageType int

MessageType -

const (
	MessageTypeInvocation MessageType = iota + 1
	MessageTypeStreamItem
	MessageTypeCompletion
	MessageTypeStreamInvocation
	MessageTypeCancelInvocation
	MessageTypePing
	MessageTypeCloseMessage
)

type NegotiateResponse

type NegotiateResponse struct {
	ConnectionToken     string               `json:"connectionToken"`
	ConnectionID        string               `json:"connectionId"`
	NegotiateVersion    int                  `json:"negotiateVersion"`
	AvailableTransports []AvailableTransport `json:"availableTransports"`
}

NegotiateResponse -

type PingMessage

type PingMessage Type

PingMessage - a `PingMessage` message

type RedirectResponse

type RedirectResponse struct {
	URL         string `json:"url"`
	AccessToken string `json:"accessToken"`
}

RedirectResponse -

type SignalR

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

SignalR -

func NewSignalR

func NewSignalR(url string) *SignalR

NewSignalR -

func (*SignalR) Close

func (s *SignalR) Close() error

Close - close connection

func (*SignalR) Connect

func (s *SignalR) Connect(version Version) error

Connect - connect to server

func (*SignalR) IsConnected added in v0.1.37

func (s *SignalR) IsConnected() bool

IsConnected -

func (*SignalR) Messages

func (s *SignalR) Messages() <-chan interface{}

Messages - listens message channel

func (*SignalR) Send

func (s *SignalR) Send(msg interface{}) error

Send - send message to server

func (*SignalR) SetOnReconnect

func (s *SignalR) SetOnReconnect(onReconnect func() error)

SetOnReconnect -

type StreamInvocation

type StreamInvocation Invocation

StreamInvocation - a `StreamInvocation` message

type StreamItem

type StreamItem struct {
	Message
	Item string `json:"item"`
}

StreamItem - a `StreamItem` message

type Transport

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

Transport -

func NewTransport

func NewTransport(baseURL string) *Transport

NewTransport -

func (*Transport) Negotiate

func (t *Transport) Negotiate(version Version) (response NegotiateResponse, err error)

Negotiate - is used to establish a connection between the client and the server.

type Type

type Type struct {
	Type MessageType `json:"type"`
}

Type -

type Version

type Version string

Version - protocol version

const (
	Version0 Version = "0"
	Version1 Version = "1"
)

Versions

Jump to

Keyboard shortcuts

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