websocket

package
v0.54.1 Latest Latest
Warning

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

Go to latest
Published: Mar 29, 2024 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Upgrader = websocket.Upgrader{
	CheckOrigin: func(r *http.Request) bool { return true },
}

Functions

This section is empty.

Types

type Broker

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

func NewBroker

func NewBroker() *Broker

func (*Broker) Init

func (b *Broker) Init(ctx context.Context, gorts *sdk.GoRoutines, pubSub cache.PubSub)

Init the websocketBroker

func (*Broker) OnMessage

func (b *Broker) OnMessage(f func(m []byte))

type Client

type Client interface {
	UUID() string
	Listen(context.Context, *sdk.GoRoutines) error
	OnMessage(func([]byte))
	Send(interface{}) error
	Close()
}

func NewClient

func NewClient(conn *websocket.Conn) Client

type CommonClient

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

func (*CommonClient) Close

func (c *CommonClient) Close()

func (*CommonClient) Listen

func (c *CommonClient) Listen(ctx context.Context, gorts *sdk.GoRoutines) error

func (*CommonClient) OnMessage

func (c *CommonClient) OnMessage(f func([]byte))

func (*CommonClient) Send

func (c *CommonClient) Send(m interface{}) (err error)

func (*CommonClient) UUID

func (c *CommonClient) UUID() string

type Server

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

func NewServer

func NewServer() *Server

func (*Server) AddClient

func (s *Server) AddClient(c Client)

func (*Server) ClientIDs

func (s *Server) ClientIDs() []string

func (*Server) Close

func (s *Server) Close()

func (*Server) RemoveClient

func (s *Server) RemoveClient(uuid string)

func (*Server) SendToClient

func (s *Server) SendToClient(uuid string, i interface{}) error

Jump to

Keyboard shortcuts

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