websockets

package
v0.9.9 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2025 License: MIT Imports: 13 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
	// contains filtered or unexported fields
}

type Config added in v0.8.0

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

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(msg *Message)

type Server

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

func NewServer

func NewServer(ctx context.Context) *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) Register added in v0.8.0

func (s *Server) Register(client *Client)

func (*Server) RegisterHandler added in v0.8.0

func (s *Server) RegisterHandler() (<-chan Message, func())

func (*Server) Run added in v0.7.1

func (s *Server) Run()

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) Unregister added in v0.8.0

func (s *Server) Unregister(client *Client)

type WSClient added in v0.8.0

type WSClient struct {
	ClientID string

	TLSConfig *tls.Config

	IsConnected bool
	// contains filtered or unexported fields
}

func NewWSClient added in v0.8.0

func NewWSClient(ctx context.Context, config Config, tlsConfig *tls.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() 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(msg Message) error

func (*WSClient) Start added in v0.8.0

func (c *WSClient) Start()

Jump to

Keyboard shortcuts

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