nado

package module
v0.0.0-...-7cd6839 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2015 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Error = log.New(os.Stderr, "ERROR ", log.Lshortfile|log.LstdFlags)
	Debug = log.New(os.Stderr, "DEBUG ", log.Lshortfile|log.LstdFlags)
)
View Source
var RouterToConsumer Header
View Source
var Stop = make(chan bool)
View Source
var Users = new(UserList)
View Source
var WriteToServer = make(chan RequestResponse)

Functions

func AddServerHandle

func AddServerHandle(handle ServeHandle)

func GetWait

func GetWait(id uint64) (b chan []byte, c chan bool, t *time.Timer, e error)

func HandFunc

func HandFunc(typ uint16, fun Header)

func NewConfig

func NewConfig(jsonFile string) *Configure

func NewServer

func NewServer(conf *Configure)

func RunHand

func RunHand(w ResponseWrite, r Request, fun Header)

func ServerListen

func ServerListen()

func StopId

func StopId(id uint64)

func UserAdd

func UserAdd(key interface{}, info UserConn) error

func UserDel

func UserDel(key interface{}) error

func UserSet

func UserSet(key interface{}, info UserConn) error

func WaitId

func WaitId(id uint64, callback func()) (b chan []byte, c chan bool, t *time.Timer)

Types

type NadoServer

type NadoServer struct {
	sync.RWMutex

	AddRoute chan *UserRoute
	DelRoute chan uint64
	Routes   map[uint64]chan []byte
	// contains filtered or unexported fields
}
var DefaultServer *NadoServer

** 默认处理方式 *

func (*NadoServer) AddServeHandle

func (self *NadoServer) AddServeHandle(s ServeHandle)

func (*NadoServer) HandFunc

func (self *NadoServer) HandFunc(typ uint16, fun Header)

func (*NadoServer) Run

func (self *NadoServer) Run()

启动一个通道服务

func (*NadoServer) RunHandler

func (self *NadoServer) RunHandler(w ResponseWrite, r Request, defaultFun Header)

type UserConn

type UserConn interface {
	Write([]byte) (int, error)
	Close() error
}

func UserGet

func UserGet(key interface{}) (UserConn, error)

type UserList

type UserList struct {
	sync.RWMutex

	L map[interface{}]UserConn
}

func (*UserList) Add

func (self *UserList) Add(key interface{}, val UserConn) (err error)

func (*UserList) Del

func (self *UserList) Del(key interface{}) (err error)

func (*UserList) Get

func (self *UserList) Get(key interface{}) (info UserConn, err error)

func (*UserList) Set

func (self *UserList) Set(key interface{}, val UserConn) (err error)

type UserRoute

type UserRoute struct {
	Uid   uint64
	Route chan []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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