ws

package
v0.0.0-...-0d61b12 Latest Latest
Warning

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

Go to latest
Published: Nov 30, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddClientSideHandler

func AddClientSideHandler(ctx *h.RequestContext, event string, handler Handler) *h.AttributeMapOrdered

func AddServerSideHandler

func AddServerSideHandler(ctx *h.RequestContext, event string, handler Handler) *h.AttributeMapOrdered

func BroadcastServerSideEvent

func BroadcastServerSideEvent(event string, value map[string]any)

BroadcastServerSideEvent sends a server side event to all clients that have a handler for the event, not just the current session

func Every

func Every(ctx *h.RequestContext, interval time.Duration, cb func() bool)

Every executes the given callback every interval, until the socket is disconnected, or the callback returns false.

func ManagerFromCtx

func ManagerFromCtx(ctx *h.RequestContext) *wsutil.SocketManager

func OnClick

func OnClick(ctx *h.RequestContext, handler Handler) *h.AttributeMapOrdered

func OnClientEvent

func OnClientEvent(ctx *h.RequestContext, eventName string, handler Handler) *h.AttributeMapOrdered

func OnMouseOver

func OnMouseOver(ctx *h.RequestContext, handler Handler) *h.AttributeMapOrdered

func OnServerEvent

func OnServerEvent(ctx *h.RequestContext, eventName string, handler Handler) h.Ren

func Once

func Once(ctx *h.RequestContext, cb func())

func PushElement

func PushElement(data HandlerData, el *h.Element) bool

PushElement sends an element to the current session and swaps it into the page

func PushElementCtx

func PushElementCtx(ctx *h.RequestContext, el *h.Element) bool

PushElementCtx sends an element to the current session and swaps it into the page

func PushServerSideEvent

func PushServerSideEvent(data HandlerData, event string, value map[string]any)

PushServerSideEvent sends a server side event this specific session

func RunOnConnected

func RunOnConnected(ctx *h.RequestContext, cb func())

func StartListener

func StartListener(locator *service.Locator)

Types

type Handler

type Handler func(data HandlerData)

type HandlerData

type HandlerData struct {
	SessionId session.Id
	Socket    *wsutil.SocketConnection
	Manager   *wsutil.SocketManager
}

type HandlerMetrics

type HandlerMetrics struct {
	TotalHandlers               int
	ServerEventNamesToHashCount int
	SessionIdToHashesCount      int
}

func GetHandlerMetics

func GetHandlerMetics() HandlerMetrics

type KeyHash

type KeyHash = string

type MessageHandler

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

func NewMessageHandler

func NewMessageHandler(manager *wsutil.SocketManager) *MessageHandler

func (*MessageHandler) OnClientSideEvent

func (h *MessageHandler) OnClientSideEvent(handlerId string, sessionId session.Id)

func (*MessageHandler) OnDomElementRemoved

func (h *MessageHandler) OnDomElementRemoved(handlerId string)

func (*MessageHandler) OnServerSideEvent

func (h *MessageHandler) OnServerSideEvent(e ServerSideEvent)

func (*MessageHandler) OnSocketDisconnected

func (h *MessageHandler) OnSocketDisconnected(event wsutil.SocketEvent)

type Metrics

type Metrics struct {
	Manager wsutil.ManagerMetrics
	Handler HandlerMetrics
}

func MetricsFromCtx

func MetricsFromCtx(ctx *h.RequestContext) Metrics

type ServerSideEvent

type ServerSideEvent struct {
	Event     string
	Payload   map[string]any
	SessionId session.Id
}

Jump to

Keyboard shortcuts

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