hub

package module
v0.0.0-...-bfac666 Latest Latest
Warning

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

Go to latest
Published: Jul 2, 2014 License: BSD-2-Clause Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RouteID  = 0
	GroupID  = 1 << 32
	ExceptID = 2 << 32
)

Variables

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

Functions

This section is empty.

Types

type Group

type Group struct {
	ID  uint64
	Hub *Hub
	sync.Mutex
	// contains filtered or unexported fields
}

func (*Group) Send

func (g *Group) Send(head string, v interface{}) error

func (*Group) SendMsg

func (g *Group) SendMsg(msg *Msg, except uint64)

func (*Group) Subscribe

func (g *Group) Subscribe(id uint64)

func (*Group) Unsubscribe

func (g *Group) Unsubscribe(id uint64)

type Hub

type Hub struct {
	sync.RWMutex

	Route chan *Msg
	// contains filtered or unexported fields
}

func New

func New() *Hub

func (*Hub) Group

func (h *Hub) Group(id uint64) *Group

func (*Hub) Send

func (h *Hub) Send(m *Msg)

func (*Hub) ServeHTTP

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

type Msg

type Msg struct {
	From, To uint64
	Head     string
	Data     []byte
}

func NewMsg

func NewMsg(from, to uint64, head string, v interface{}) (m *Msg, err error)

func (*Msg) Reply

func (m *Msg) Reply(head string, v interface{}) (*Msg, 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