ws

package
v1.0.8 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2024 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Create Connection
	EventCreateConnection = iota
	// HeartBeat
	EventHeartBeat
	// Message
	EventMessage
	// Close Socket
	EventSocketClose
	// Subscribe
	EventSubscribe
	// Reconnect
	EventReconnect
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Base

type Base struct {
	Host           string
	Ws             *Conn
	EventStream    chan *Event
	MessageHandler func(msg []byte)
	OnWSCreated    func()
	// contains filtered or unexported fields
}

func (*Base) Close

func (h *Base) Close()

func (*Base) CreateWsConn

func (h *Base) CreateWsConn(host, path string)

type Conn

type Conn struct {
	sync.RWMutex
	*websocket.Conn
	// contains filtered or unexported fields
}

func NewWsConn

func NewWsConn(host, path string, eventStream chan *Event) *Conn

func (*Conn) CloseWs

func (ws *Conn) CloseWs()

func (*Conn) Reconnect

func (ws *Conn) Reconnect(err error)

func (*Conn) Shutdown

func (ws *Conn) Shutdown()

func (*Conn) StartToHeartbeat

func (ws *Conn) StartToHeartbeat(f func() string, interval time.Duration)

func (*Conn) StartToReceiveMessage

func (ws *Conn) StartToReceiveMessage()

func (*Conn) Subscribe

func (ws *Conn) Subscribe(subEvent interface{})

func (*Conn) Write

func (ws *Conn) Write(f func())

type Event

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

Jump to

Keyboard shortcuts

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