websockets

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Jan 31, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	ID           string
	AgentVersion string
	// contains filtered or unexported fields
}

type Config added in v0.8.0

type Config struct {
	ServerURL string
	ClientID  string
	Headers   http.Header
	TLSConfig *tls.Config
}

type Message

type Message struct {
	ClientID string    `json:"client_id"`
	Type     string    `json:"type"`
	Content  string    `json:"content"`
	Time     time.Time `json:"time"`
}

type MessageHandler added in v0.8.0

type MessageHandler func(ctx context.Context, msg *Message) error

type Server

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

func NewServer

func NewServer(ctx context.Context, opts ...ServerOption) *Server

func (*Server) AgentPing added in v0.8.0

func (server *Server) AgentPing(agentTarget *types.Target) bool

func (*Server) AgentVersion added in v0.9.3

func (server *Server) AgentVersion(agentTarget *types.Target) string

func (*Server) GetClientVersion added in v0.9.2

func (s *Server) GetClientVersion(clientID string) string

func (*Server) IsClientConnected added in v0.7.1

func (s *Server) IsClientConnected(clientID string) bool

func (*Server) RegisterHandler added in v0.8.0

func (s *Server) RegisterHandler(msgType string, handler MessageHandler)

func (*Server) SendToClient added in v0.7.1

func (s *Server) SendToClient(clientID string, msg Message) error

func (*Server) ServeWS added in v0.7.1

func (s *Server) ServeWS(w http.ResponseWriter, r *http.Request)

func (*Server) Shutdown added in v0.10.0

func (s *Server) Shutdown(ctx context.Context) error

type ServerOption added in v0.10.0

type ServerOption func(*Server)

func WithWorkerPoolSize added in v0.10.0

func WithWorkerPoolSize(size int) ServerOption

type WSClient added in v0.8.0

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

func NewWSClient added in v0.8.0

func NewWSClient(ctx context.Context, config Config) (*WSClient, error)

func (*WSClient) Close added in v0.8.0

func (c *WSClient) Close() error

func (*WSClient) Connect added in v0.8.0

func (c *WSClient) Connect(ctx context.Context) error

func (*WSClient) GetConnectionStatus added in v0.8.0

func (c *WSClient) GetConnectionStatus() bool

func (*WSClient) RegisterHandler added in v0.8.0

func (c *WSClient) RegisterHandler(msgType string, handler MessageHandler)

func (*WSClient) Send added in v0.8.0

func (c *WSClient) Send(ctx context.Context, msg Message) error

type WorkerPool added in v0.10.0

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

func NewWorkerPool added in v0.10.0

func NewWorkerPool(size int) *WorkerPool

func (*WorkerPool) Submit added in v0.10.0

func (p *WorkerPool) Submit(ctx context.Context, task func()) error

func (*WorkerPool) Wait added in v0.10.0

func (p *WorkerPool) Wait()

Jump to

Keyboard shortcuts

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