Documentation ¶
Overview ¶
Package stocking is a minimal websocket framework based on http://github.com/gorilla/websocket. It provides easy-to-use APIs, for those who only wants basic functions to play with, or finish some simple jobs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client represents the... um... websocket client
type Middleware ¶
type Middleware interface {
Handle(p *HubPackge, next MiddlewareStepFunc)
}
Middleware TODO
type MiddlewareStepFunc ¶
MiddlewareStepFunc TODO
type RouterError ¶
type RouterError struct {
// contains filtered or unexported fields
}
RouterError TODO
func (RouterError) Error ¶
func (e RouterError) Error() string
type RouterHandler ¶
type RouterHandler = func(p *RouterPackage) (interface{}, error)
RouterHandler TODO
type RouterMessageProtocol ¶
type RouterMessageProtocol struct { Code int `json:"c"` Payload interface{} `json:"p"` }
RouterMessageProtocol TODO
type RouterPackage ¶
RouterPackage TODO
type Stocking ¶
type Stocking struct { // the address for http.ListenAndServe Host string // the root pattern for connection Root string // the underlying Upgrader for gorilla/websocket Upgrader websocket.Upgrader }
Stocking is the instance of the websocket server with basic configs
func NewStocking ¶
NewStocking creates and returns a new stocking, server I mean.
func (*Stocking) Attach ¶
func (s *Stocking) Attach()
Attach root handler to an existing http server
func (*Stocking) On ¶
func (s *Stocking) On(route string, handler RouterHandler, typeHint interface{})
On adds a route handler
func (*Stocking) Otherwise ¶
func (s *Stocking) Otherwise(handler RouterHandler)
Otherwise adds a fallback handler when no route hits
type TextMessageProtocol ¶
type TextMessageProtocol struct { Event string `json:"e"` Payload json.RawMessage `json:"p"` }
TextMessageProtocol TODO