ws

package module
v0.0.0-...-4bf0eed Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package ws wraps the gorilla websocket to provide a handler and maintain pinging by default.

This project is currently under development and is not fit for production use.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

A Client maintains a connection to a client.

func (*Client) Close

func (c *Client) Close(closeCode ...int)

Close attempts to inform the client before terminating the connection. Subsequent calls to Close result in a no-op.

func (*Client) Write

func (c *Client) Write(msg []byte) error

Write sends the message to the client.

type Handler

type Handler struct {
	Upgrader     websocket.Upgrader
	Logger       *log.Logger
	PingInterval time.Duration
	WriteTimeout time.Duration
	ReadTimeout  time.Duration

	ConnectListener func(*Client)
	MessageListener func(*Client, []byte)
	ErrorListener   func(*Client, error)
	CloseListener   func(*Client)
}

A Handler upgrades to a websocket and starts the client that maintains the connection.

func (*Handler) ServeHTTP

func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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