websockets

package
v1.40.9 Latest Latest
Warning

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

Go to latest
Published: May 13, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ActionType

type ActionType string
const (
	INFO    ActionType = "info"
	MESSAGE ActionType = "message"
)

type EventItem

type EventItem interface {
	WebsocketMessage | WebsocketInfo | any
}

type LocalWebsocketService

type LocalWebsocketService struct {
	*websockets.WebsocketManager
	// contains filtered or unexported fields
}

func NewLocalWebsocketService

func NewLocalWebsocketService() (*LocalWebsocketService, error)

func (*LocalWebsocketService) GetState

func (r *LocalWebsocketService) GetState() State

func (*LocalWebsocketService) HandleEvents

func (*LocalWebsocketService) RegisterConnection

func (r *LocalWebsocketService) RegisterConnection(socket string, connectionId string, connection *websocket.Conn) error

func (*LocalWebsocketService) SendMessage

func (*LocalWebsocketService) SetServers

func (r *LocalWebsocketService) SetServers(server map[string]string)

func (*LocalWebsocketService) SocketDetails

func (*LocalWebsocketService) SubscribeToAction

func (r *LocalWebsocketService) SubscribeToAction(subscription func(WebsocketAction[EventItem]))

func (*LocalWebsocketService) SubscribeToState

func (r *LocalWebsocketService) SubscribeToState(subscription func(map[string]map[string][]nitricws.WebsocketEventType))

type State

type State = map[socketName]map[serviceName][]nitricws.WebsocketEventType

type WebsocketAction

type WebsocketAction[Event EventItem] struct {
	Name  string     `json:"name"`
	Event Event      `json:"event"`
	Type  ActionType `json:"-"`
}

type WebsocketInfo

type WebsocketInfo struct {
	ConnectionCount int                `json:"connectionCount,omitempty"`
	Messages        []WebsocketMessage `json:"messages,omitempty"`
}

type WebsocketMessage

type WebsocketMessage struct {
	Data         string    `json:"data,omitempty"`
	Time         time.Time `json:"time,omitempty"`
	ConnectionID string    `json:"connectionId,omitempty"`
}

Jump to

Keyboard shortcuts

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