ledserv

package module
v0.0.0-...-d4db22b Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2019 License: MIT Imports: 10 Imported by: 2

README

franeklubi/ledserv

GoDoc

Package ledserv provides an easy way to send ledgend's Change information to any websocket client.

A client implementation for esp8266 can be found in the ledgend-esp8266 repository.

Documentation

Overview

Package ledserv provides an easy way to send github.com/franeklubi/ledgend's Change information to any websocket client.

Information is sent in the following form:

The type of payload is []byte

payload[0] (preambule) contains information about options, that change the
way the payload should be read:
Reserved options:
    - (payload[0] & 0x0F) - indicates how many bytes long the Changes'
        addresses will be
        (takes on the value of 2 when at least one of the Changes'
        address is above 255)

    - The rest of preambule's space is reserved for the situation
        there is ever a need to send over more options

Let's assume the preambule tells us address length is == 1:
payload[1] - Change's address
payload[2] - Change's R value
payload[3] - Change's G value
payload[4] - Change's B value

The broadcast of ledserv's IP address looks like this:

"ledgend;"+address

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Broadcast

func Broadcast(ms float64)

Broadcast starts a broadcast of the server's IP on all available interfaces

Takes in the number of milliseconds to wait between each broadcast

func ClientsConnected

func ClientsConnected() int

ClientsConnected returns the number of clients currently connected to the ledserv's websocket

func InitServer

func InitServer(port uint16) (chan<- []ledgend.Change, error)

InitServer initializes the ledserv's server on provided port

Two and only endpoints are "/" and "/ws"

"/ws" lets You establish a websocket connection

"/" informs the user user about the "/ws" endpoint

Returns a channel You can send []ledgend.Change to, that will be sent to all connected clients

func StopBroadcast

func StopBroadcast()

StopBroadcast stops the broadcast started by Broadcast()

Types

This section is empty.

Jump to

Keyboard shortcuts

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