hub

package
v0.0.0-...-0f24718 Latest Latest
Warning

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

Go to latest
Published: May 13, 2016 License: BSD-2-Clause Imports: 9 Imported by: 3

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Signon  = "_signon"
	Signoff = "_signoff"
)

Functions

This section is empty.

Types

type Envelope

type Envelope struct {
	From, To Id
	Msg
}

type Grouper

type Grouper interface {
	GroupId() Id
	Group() []Id
}

type Hub

type Hub struct {
	Add   chan Grouper
	Del   chan Grouper
	Route chan Envelope
	Send  chan Envelope
	// contains filtered or unexported fields
}

func New

func New() *Hub

func (*Hub) SendMsg

func (h *Hub) SendMsg(m Msg, to Id)

func (*Hub) ServeHTTP

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

type Id

type Id int64
const (
	Route  Id = 0
	Group  Id = 1 << 32
	Except Id = 2 << 32
)

func (Id) MarshalJSON

func (id Id) MarshalJSON() ([]byte, error)

func (*Id) UnmarshalJSON

func (id *Id) UnmarshalJSON(data []byte) error

type Msg

type Msg struct {
	Head string
	Data *json.RawMessage `json:",omitempty"`
}

func Marshal

func Marshal(head string, v interface{}) (m Msg, err error)

func (*Msg) Unmarshal

func (m *Msg) Unmarshal(v interface{}) error

Jump to

Keyboard shortcuts

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