model

package
v1.3.4 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2023 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Addr = flag.String("addr", ":3007", "http service address")
View Source
var HUB = &Hub{}
View Source
var Upgrader = websocket.Upgrader{
	ReadBufferSize:  1024,
	WriteBufferSize: 1024,

	CheckOrigin: func(r *http.Request) bool {
		return true
	},
}

Functions

func AppendDataWithTimeToFile

func AppendDataWithTimeToFile(data string) error

func AppendStringToFile added in v1.1.0

func AppendStringToFile(data string, fileLabel string) error

func AppendStringToFileDirect added in v1.2.2

func AppendStringToFileDirect(data string, file *os.File) error

func AppendToFile added in v1.1.0

func AppendToFile(data []byte, fileLabel string) error

func AppendToFileDirect added in v1.2.2

func AppendToFileDirect(data []byte, file *os.File) error

func CreateFileWithTimestamp

func CreateFileWithTimestamp() error

func OpenFile

func OpenFile(*menu.CallbackData)

func SerialInit

func SerialInit(selectedPort string) (string, error)

Types

type Client

type Client struct {
	Hub *Hub

	// Buffered channel of outbound messages.
	Send chan []byte
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the hub.

func NewClient

func NewClient(hub *Hub, conn *websocket.Conn) *Client

func (*Client) ReadPump

func (c *Client) ReadPump()

readPump pumps messages from the websocket connection to the hub.

The application runs readPump in a per-connection goroutine. The application ensures that there is at most one reader on a connection by executing all reads from this goroutine.

func (*Client) WritePump

func (c *Client) WritePump()

writePump pumps messages from the hub to the websocket connection.

A goroutine running writePump is started for each connection. The application ensures that there is at most one writer to a connection by executing all writes from this goroutine.

type Hub

type Hub struct {
	// Registered clients.
	Clients map[*Client]bool

	// Inbound messages from the clients.
	Broadcast chan []byte

	// Register requests from the clients.
	Register chan *Client

	// Unregister requests from clients.
	Unregister chan *Client
}

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub() *Hub

func (*Hub) SendError

func (h *Hub) SendError(text string)

func (*Hub) SendText

func (h *Hub) SendText(text string)

Jump to

Keyboard shortcuts

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