ws

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrConnectionClosed = errors.New("connection is closed")
	ErrClientConnClosed = errors.New("client connection is closed")
)

Functions

func ClientIp

func ClientIp(r *http.Request) string

func Handler

func Handler(ctx context.Context, origin bool, heartbeatInterval int64, receive func(*Connection)) func(w http.ResponseWriter, r *http.Request)

Types

type Connection

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

func NewConnection

func NewConnection(ctx context.Context, conn *websocket.Conn, realIP string, heartbeatInterval int64) *Connection

func (*Connection) Close

func (c *Connection) Close()

func (*Connection) HeartbeatChecker

func (c *Connection) HeartbeatChecker()

func (*Connection) IsAlive

func (c *Connection) IsAlive() bool

func (*Connection) KeepAlive

func (c *Connection) KeepAlive()

func (*Connection) ReadMessage

func (c *Connection) ReadMessage() ([]byte, error)

func (*Connection) RemoteAddr

func (c *Connection) RemoteAddr() net.Addr

func (*Connection) RemoteRealIP

func (c *Connection) RemoteRealIP() string

func (*Connection) WriteMessage

func (c *Connection) WriteMessage(data []byte) error

Jump to

Keyboard shortcuts

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