hub

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

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

Go to latest
Published: Dec 18, 2017 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_UNAVAIABLE = 1
	STATE_AVAIABLE   = 2
)

Variables

View Source
var (
	ERR_HANDLER_EXIST = errors.New("handler exists")
)

Functions

func GetBeforeHandler

func GetBeforeHandler() func(*Session, string) error

func GetHandler

func GetHandler(handleId int) (func(*Session, []byte) []byte, error)

func GetHandlerId

func GetHandlerId(name string) (int, error)

func GetHandlerName

func GetHandlerName(handlerId int) (string, error)

func GetHandlers

func GetHandlers() []byte

func GetRouteHandler

func GetRouteHandler(serverType string) func(*Session) string

func HandleFunc

func HandleFunc(name string, handler func(*Session, []byte) []byte)

func NotFound

func NotFound() []byte

func RegisterBeforeHandler

func RegisterBeforeHandler(handler func(*Session, string) error)

func RegisterHandle

func RegisterHandle(name string)

func Route

func Route(serverType string, handler func(session *Session) string)

func UniqueId

func UniqueId() string

Types

type Connection

type Connection interface {
	Close() error
}

type Hub

type Hub struct {
	Sessions   map[string]*Session
	Register   chan *Session
	Unregister chan *Session
	Closed     chan bool
	// contains filtered or unexported fields
}

func GetHub

func GetHub() *Hub

func NewHub

func NewHub() *Hub

func (*Hub) GetSessionById

func (hub *Hub) GetSessionById(id string) *Session

func (*Hub) Kick

func (hub *Hub) Kick(session *Session)

func (*Hub) Run

func (hub *Hub) Run()

func (*Hub) Size

func (hub *Hub) Size() int

func (*Hub) Stop

func (hub *Hub) Stop()

type Session

type Session struct {
	Id   string
	Conn Connection
	Send chan []byte
	// contains filtered or unexported fields
}

func (*Session) Bind

func (session *Session) Bind(name string, handler func())

func (*Session) Close

func (session *Session) Close()

func (*Session) Get

func (session *Session) Get(key string) interface{}

func (*Session) GetClientConn

func (session *Session) GetClientConn(serverType string) *grpc.ClientConn

func (*Session) HandleData

func (session *Session) HandleData(data []byte)

func (*Session) Kick

func (session *Session) Kick(data []byte)

func (*Session) Push

func (session *Session) Push(route string, data []byte)

func (*Session) Set

func (session *Session) Set(key string, value interface{})

func (*Session) Trigger

func (session *Session) Trigger(name string)

func (*Session) Write

func (session *Session) Write(data []byte)

Jump to

Keyboard shortcuts

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