core

package
v0.0.0-...-d02dc53 Latest Latest
Warning

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

Go to latest
Published: Jan 16, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateResultsFromJSON

func GenerateResultsFromJSON(results []map[string]interface{}) string

Types

type A

type A struct {
	Title       string
	Description string
	Name        string
}

type Client

type Client struct {
	Hub *Hub

	// The websocket connection.
	Conn *websocket.Conn

	// Buffered channel of outbound messages.
	Send chan []byte
}

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

type Core

type Core struct{}

func NewCore

func NewCore() *Core

func (*Core) Init

func (c *Core) Init()

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 InitWebSocketHub

func InitWebSocketHub() *Hub

InitWebSocketHub initialize websocket hub

func (*Hub) Run

func (h *Hub) Run()

type Message

type Message struct {
	ID        string      `json:"id"`
	Type      string      `json:"type"`
	Content   string      `json:"content"`
	Data      interface{} `json:"data"`
	Timestamp time.Time   `json:"timestamp"`
}

func NewErrorMessage

func NewErrorMessage() Message

func NewErrorMessageWithContent

func NewErrorMessageWithContent(text string) Message

func NewInvalidFormatErrorMessage

func NewInvalidFormatErrorMessage() Message

func NewIvalidTypeErrorMessage

func NewIvalidTypeErrorMessage() Message

func NewMarshalJSONErrorMessage

func NewMarshalJSONErrorMessage() Message

func NewMessage

func NewMessage() Message

func (Message) JSONMarshal

func (m Message) JSONMarshal() []byte

Jump to

Keyboard shortcuts

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