ws

package
v0.0.0-...-60b8695 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2021 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultConfig = Config{
	UseTrafficTLSAddress: false,
	WSPingInterval:       30 * time.Second,
	AllowUnauthenticated: false,
}

DefaultConfig contains the default configuration.

Functions

func New

func New(ctx context.Context, server io.Server, formatter Formatter, cfg Config) *echo.Echo

New creates a new WebSocket frontend.

func NewContextWithSession

func NewContextWithSession(ctx context.Context, session *Session) context.Context

NewContextWithSession returns a new context with the session.

Types

type Config

type Config struct {
	UseTrafficTLSAddress bool          `name:"use-traffic-tls-address" description:"Use WSS for the traffic address regardless of the TLS setting"`
	WSPingInterval       time.Duration `name:"ws-ping-interval" description:"Interval to send WS ping messages"`
	AllowUnauthenticated bool          `name:"allow-unauthenticated" description:"Allow unauthenticated connections"`
}

Config defines the LoRa Basics Station configuration of the Gateway Server.

type Endpoints

type Endpoints struct {
	ConnectionInfo string
	Traffic        string
}

Endpoints contains the connection endpoints for the protocol

type Formatter

type Formatter interface {
	// Endpoints fetches the connection endpoints for the protocol.
	Endpoints() Endpoints
	// HandleConnectionInfo handles connection information requests from web socket based protocols.
	// This function returns a byte stream that contains connection information (ex: scheme, host, port etc) or an error if applicable.
	HandleConnectionInfo(ctx context.Context, raw []byte, server io.Server, serverInfo ServerInfo, receivedAt time.Time) []byte
	// HandleUp handles upstream messages from web socket based gateways.
	// This function optionally returns a byte stream to be sent as response to the upstream message.
	HandleUp(ctx context.Context, raw []byte, ids ttnpb.GatewayIdentifiers, conn *io.Connection, receivedAt time.Time) ([]byte, error)
	// FromDownlink generates a downlink byte stream that can be sent over the WS connection.
	FromDownlink(ctx context.Context, uid string, down ttnpb.DownlinkMessage, concentratorTime scheduling.ConcentratorTime, dlTime time.Time) ([]byte, error)
}

Formatter abstracts messages to/from websocket based gateways.

type ServerInfo

type ServerInfo struct {
	Scheme  string
	Address string
}

ServerInfo contains information on the WebSocket server.

type Session

type Session struct {
	DataMu sync.Mutex
	Data   interface{}
}

Session contains the session state for a single gateway.

func SessionFromContext

func SessionFromContext(ctx context.Context) *Session

SessionFromContext returns a new session from the context. The session value can be modified by the caller.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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