websocket

package
v0.0.0-...-8d4a447 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Upgrade

func Upgrade(w http.ResponseWriter, r *http.Request) (*websocket.Conn, error)

Types

type Connection

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

func NewConnection

func NewConnection(conn *websocket.Conn, pool *Pool) *Connection

func (*Connection) Close

func (c *Connection) Close(status websocket.StatusCode, reason string)

func (*Connection) WriteBinary

func (c *Connection) WriteBinary(body []byte) error

func (*Connection) WriteJSON

func (c *Connection) WriteJSON(body interface{}) error

func (*Connection) WriteText

func (c *Connection) WriteText(body []byte) error

type Message

type Message struct {
	Type websocket.MessageType `json:"type"`
	Body string                `json:"body"`
}

type Pool

type Pool struct {
	Register      chan *Connection
	Unregister    chan *Connection
	Connections   map[*Connection]bool
	BroadcastJSON chan interface{}
}

func NewPool

func NewPool() *Pool

func (*Pool) Start

func (pool *Pool) Start()

Jump to

Keyboard shortcuts

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