websocket

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2023 License: Apache-2.0 Imports: 5 Imported by: 0

README

websocket

Documentation

Overview

Package websocket

Package client

Package websocket

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	GroupName string
	Group     GroupAPI

	// The websocket connection.
	Conn *websocket.Conn
	// Buffered channel of outbound messages.
	Send chan []byte
	// contains filtered or unexported fields
}

Client is a middleman between the websocket connection and the group.

func NewWS

func NewWS(w http.ResponseWriter, r *http.Request, upgrade *websocket.Upgrader) (*Client, error)

func (*Client) Close

func (c *Client) Close()

func (*Client) Run

func (c *Client) Run()

func (*Client) SendMsg

func (c *Client) SendMsg(msg string)

func (*Client) SetCloseCallback

func (c *Client) SetCloseCallback(f func(data interface{}))

func (*Client) SetData

func (c *Client) SetData(data interface{})

func (*Client) SetDealMsg

func (c *Client) SetDealMsg(f func(msg []byte) []byte)

type GroupAPI

type GroupAPI interface {
	Register(cli *Client)
	UnRegister(cli *Client)
	SendMsg(msg []byte)
}

type GroupExtData

type GroupExtData struct {
	CloseSendData interface{}
	CloseCallback func(data interface{})
	ReceiveMsg    func(msg []byte) []byte
}

Directories

Path Synopsis
Package config
Package config
Package websocket
Package websocket
Package multisub
Package multisub
Package simplesub
Package simplesub
Package singlesub
Package singlesub

Jump to

Keyboard shortcuts

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