websocket

package
v0.6.0-rc2 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2023 License: Apache-2.0 Imports: 10 Imported by: 1

README

Grav Transport: Websocket

This is a streaming transport plugin for Grav that uses standard websockets.

Handler functions are made available for http.Server. Connections are managed by the Transport object.

Documentation

Index

Constants

View Source
const (
	MsgTypeWebsocketMessage = "websocket.message"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

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

Conn implements transport.Connection and represents a websocket connection

func (*Conn) Close

func (c *Conn) Close() error

Close closes the underlying connection

func (*Conn) IncomingHandshake

func (c *Conn) IncomingHandshake(handshakeCallback bus.HandshakeCallback) error

IncomingHandshake performs a connection handshake and returns the UUID of the node that we're connected to so that it can be validated against the UUID that was provided in discovery (or if none was provided)

func (*Conn) OutgoingHandshake

func (c *Conn) OutgoingHandshake(handshake *bus.TransportHandshake) (*bus.TransportHandshakeAck, error)

OutgoingHandshake performs a connection handshake and returns the UUID of the node that we're connected to so that it can be validated against the UUID that was provided in discovery (or if none was provided)

func (*Conn) ReadMsg

func (c *Conn) ReadMsg() (bus.Message, *bus.Withdraw, error)

func (*Conn) SendMsg

func (c *Conn) SendMsg(msg bus.Message) error

SendMsg sends a message to the connection

func (*Conn) SendWithdraw

func (c *Conn) SendWithdraw(withdraw *bus.Withdraw) error

SendWithdraw sends a withdraw message to the peer

func (*Conn) WriteMessage

func (c *Conn) WriteMessage(messageType int, data []byte) error

WriteMessage is a concurrent-safe wrapper around the websocket WriteMessage

type Transport

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

Transport is a transport that connects Grav nodes via standard websockets

func New

func New() *Transport

New creates a new websocket transport

func (*Transport) Connect

func (t *Transport) Connect(endpoint string) (bus.Connection, error)

Connect adds a websocket endpoint to emit messages to

func (*Transport) HTTPHandlerFunc

func (t *Transport) HTTPHandlerFunc() http.HandlerFunc

HTTPHandlerFunc returns an http.HandlerFunc for incoming connections

func (*Transport) Setup

func (t *Transport) Setup(opts *bus.MeshOptions, connFunc bus.ConnectFunc) error

Setup sets up the transport

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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