typesocket

package
v0.0.0-...-6b33518 Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2019 License: AGPL-3.0-or-later Imports: 11 Imported by: 6

Documentation

Overview

Package typesocket implements a websocket server and client.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientConn

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

func Dial

func Dial(addr string, peerKey ed25519.PublicKey) (*ClientConn, error)

func (*ClientConn) Close

func (c *ClientConn) Close() error

func (*ClientConn) Send

func (c *ClientConn) Send(msgID string, v interface{}) error

func (*ClientConn) Serve

func (c *ClientConn) Serve(mux Mux) error

type Conn

type Conn interface {
	Send(msgID string, v interface{}) error

	Close() error
}

type Hub

type Hub struct {
	Mux Mux

	// OnConnect is called when a client connects to the server.
	OnConnect func(Conn) error
	// contains filtered or unexported fields
}

func (*Hub) Broadcast

func (h *Hub) Broadcast(msgID string, v interface{}) error

func (*Hub) ServeHTTP

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

type Mux

type Mux map[string]*muxEntry

func NewMux

func NewMux(handlers map[string]interface{}) Mux

NewMux creates a new mux from the given handlers. The key in the handlers map is a message ID and the interface{} value must be of type func(Conn, T) for some type T.

Jump to

Keyboard shortcuts

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