websocket

package
v0.0.0-...-c577d06 Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

View Source
const (
	HashAlgoNone   = 0
	HashAlgoMD5    = 1
	HashAlgoSHA256 = 2
)
View Source
const LogRegioWsClient = "websocket client"
View Source
const LogRegioWsServer = "ws server"

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHeader

type AuthHeader struct {
	HeaderRequired map[string]string
	ValueHashAlgo  HashAlgo
}

func NewAuthHeader

func NewAuthHeader(headerKey string, headerValue string, valueHashAlgo HashAlgo) *AuthHeader

type Client

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

func NewClient

func NewClient(skipCertValidation bool, eventHandler Events) *Client

func (*Client) AddRootCa

func (c *Client) AddRootCa(rootCA []byte)

func (*Client) ConnectAndServe

func (c *Client) ConnectAndServe(url string,
	header map[string]string) (err error)

func (*Client) DisableCommonNameCheck

func (c *Client) DisableCommonNameCheck()

func (*Client) Disconnect

func (c *Client) Disconnect() (err error)

func (*Client) Send

func (c *Client) Send(message Message) (err error)

func (*Client) SendTxt

func (c *Client) SendTxt(message []byte) (err error)

type Event

type Event struct {
	Err  error
	Type EventType
	Id   int
}

type EventType

type EventType int
const (
	Connect         EventType = 1
	Disconnect      EventType = 0
	Failure         EventType = -1
	FailureWithExit EventType = -2
)

type Events

type Events interface {
	OnReceive(msg Message)
	OnDisconnect(id int)
	OnConnect(id int)
	OnFailure(exited bool, err error)
}

type EventsToChannel

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

func NewEventsToChannel

func NewEventsToChannel(messageChannel chan<- Message,
	eventChannel chan<- Event) *EventsToChannel

func (*EventsToChannel) OnConnect

func (t *EventsToChannel) OnConnect(id int)

func (*EventsToChannel) OnDisconnect

func (t *EventsToChannel) OnDisconnect(id int)

func (*EventsToChannel) OnFailure

func (t *EventsToChannel) OnFailure(exited bool, err error)

func (*EventsToChannel) OnReceive

func (t *EventsToChannel) OnReceive(msg Message)

type HashAlgo

type HashAlgo int

type Message

type Message struct {
	MessageType int
	Data        []byte
	ClientId    int
}

type Server

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

func NewServer

func NewServer(url string,
	eventHander Events) *Server

func (*Server) Broadcast

func (s *Server) Broadcast(message *Message)

func (*Server) Close

func (s *Server) Close() (err error)

func (*Server) ListenAndServe

func (s *Server) ListenAndServe() (err error)

func (*Server) Send

func (s *Server) Send(clientId int, message *Message) error

func (*Server) SetAuthHeader

func (s *Server) SetAuthHeader(authHeader *AuthHeader)

func (*Server) SetupTls

func (s *Server) SetupTls(certificate []byte, privateKey []byte)

Jump to

Keyboard shortcuts

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