http

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2021 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// How long (in bytes) the random IDs should be
	ID_LEN = 6

	// How many messages to queue for the client before the connection
	// is dropped for being too slow.
	BUF_LEN = 16
)
View Source
const (
	// Challenge passed.
	WS_CHALLENGE_SUCCESS = iota + 4000

	// Server expects the next client message to contain a password.
	WS_CHALLENGE_PASSWORD
)

Application-defined status codes. See: https://tools.ietf.org/html/rfc6455#section-7.4.2

Challenge responses

View Source
const (
	// Malformed message data received.
	WS_ERROR_BAD_MSG = iota + 4400

	// Invalid login attempt.
	WS_ERROR_UNAUTHORISED

	// Permission denied.
	WS_ERROR_FORBIDDEN

	// Object not found.
	WS_ERROR_NOT_FOUND

	// Took too long responding.
	WS_ERROR_TIMEOUT

	// Publisher/subscriber channel is full and the client cannot be added
	// until a publisher/subscriber disconnects.
	WS_ERROR_CHANNEL_FULL
)

Error codes

View Source
const (
	// Maximum number of clients listening.
	MAX_SUBS = 10
)
View Source
const (
	// No error occurred in the last message.
	WS_OK = iota + 4200
)

Informational

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

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

CRUD controller that manipulates channel data in the provided repository.

func NewChannel

func NewChannel(channels are_hub.ChannelRepo) Channel

Create a new channel controller.

func (Channel) Delete

func (c Channel) Delete(w http.ResponseWriter, r *http.Request) error

Delete a specific channel by its ID.

func (Channel) Index

func (c Channel) Index(w http.ResponseWriter, r *http.Request) error

Get all channels.

func (Channel) Show

func (c Channel) Show(w http.ResponseWriter, r *http.Request) error

Find a specific channel by its ID.

func (Channel) Store

func (c Channel) Store(w http.ResponseWriter, r *http.Request) error

Create a new channel.

func (Channel) Update

func (c Channel) Update(w http.ResponseWriter, r *http.Request) error

Update a specific channel by its ID.

type TelemetryServer

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

Handles receiving data from publishers and forwarding that data along to subscribers on the same channel.

func NewTelemetryServer

func NewTelemetryServer(o *websocket.AcceptOptions, r are_hub.ChannelRepo) *TelemetryServer

Create a new telemetry server.

func (*TelemetryServer) Publish

func (ts *TelemetryServer) Publish(w http.ResponseWriter, r *http.Request) error

Broadcast messages to connected clients (connected via websockets).

func (*TelemetryServer) Subscribe

func (ts *TelemetryServer) Subscribe(w http.ResponseWriter, r *http.Request) error

Handle upgrade subscriber clients to a websocket.

Directories

Path Synopsis
middleware

Jump to

Keyboard shortcuts

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