riot

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2024 License: MIT-0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Codec

type Codec interface {
	Encode(w io.Writer, msg *igtimi.Msg) error
	Decode(r Reader, msg *igtimi.Msg) error
}

type CodecJson

type CodecJson struct{}

func (*CodecJson) Decode

func (c *CodecJson) Decode(r Reader, msg *igtimi.Msg) error

func (*CodecJson) Encode

func (c *CodecJson) Encode(w io.Writer, msg *igtimi.Msg) error

type CodecProto

type CodecProto struct{}

func (*CodecProto) Decode

func (c *CodecProto) Decode(r Reader, msg *igtimi.Msg) error

func (*CodecProto) Encode

func (c *CodecProto) Encode(w io.Writer, msg *igtimi.Msg) error

type CodecType

type CodecType int
const (
	CodecTypeProto CodecType = iota
	CodecTypeJson
)

type Reader

type Reader interface {
	io.Reader
	io.ByteReader
}

type Server

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

func NewServer

func NewServer(ctx context.Context, config ServerConfig) (*Server, error)

func (*Server) GetConnections

func (s *Server) GetConnections() []*ServerConnection

GetConnections returns a list of all active connections

func (*Server) Send

func (s *Server) Send(serial string, msg *igtimi.Msg) error

Send sends a message to a specific device

func (*Server) Subscribe

func (s *Server) Subscribe() (<-chan *igtimi.Msg, UnsubscribeFunc)

Subscribe returns a channel that receives messages from all connected clients and an unsubscribe function, which should be called when the subscription is no longer needed

type ServerConfig

type ServerConfig struct {
	Address string
	Codec   CodecType
}

type ServerConnection

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

ServerConnection represents a connection to a client

func (*ServerConnection) GetInfo

func (s *ServerConnection) GetInfo() map[string]string

GetInfo returns the device metadata

func (*ServerConnection) GetSerial

func (s *ServerConnection) GetSerial() *string

GetSerial returns the serial number of the device or nil if the serial number is not yet known

func (*ServerConnection) Send

func (s *ServerConnection) Send(msg *igtimi.Msg) error

Send sends a message to the client

type UnsubscribeFunc

type UnsubscribeFunc func()

Jump to

Keyboard shortcuts

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