Documentation ¶
Index ¶
- func MarshallCommands(cmds ...CmdNamer) []byte
- func NewHandler(f handlerFunc, middleware []MiddlewareFunc) *handler
- type ClientCommandDesciption
- type Closer
- type CmdNamer
- type CommandIn
- type CommandOut
- type Conn
- type Connection
- type Describer
- type EmptyLogger
- type ErrorCommand
- type FakeConn
- type IRouter
- type Logger
- type MiddlewareFunc
- type PacketIn
- type PacketOut
- type Router
- func (self *Router) DescribeApi(tm map[reflect.Type]string) (scmds []*ServerCommandDesciption, ccmds []*ClientCommandDesciption)
- func (self *Router) ProcessCommand(conn Conn, version int, command string, data json.RawMessage) (res []CommandOut)
- func (self *Router) ProcessPacket(conn Conn, packetBuf []byte)
- func (self *Router) RegisterApiHandler(version int, command string, handler handlerFunc)
- func (self *Router) RegisterApiHandlerWithMiddleware(version int, command string, handler handlerFunc, middle []MiddlewareFunc)
- func (self *Router) RegisterGetVersion(cb func(conn Conn) int)
- func (self *Router) SetLogger(l Logger)
- func (self *Router) With(mw MiddlewareFunc) *middlewareWrapper
- type Server
- type ServerCommandDesciption
- type ServerOpts
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshallCommands ¶ added in v0.0.2
func NewHandler ¶
func NewHandler(f handlerFunc, middleware []MiddlewareFunc) *handler
Types ¶
type ClientCommandDesciption ¶
type ClientCommandDesciption struct { Name string Params interface{} }
type CommandIn ¶
type CommandIn struct { Name string `json:"name"` Data json.RawMessage `json:"data,omitempty"` }
type CommandOut ¶
type CommandOut struct { Name string `json:"name"` Data interface{} `json:"data,omitempty"` }
type Connection ¶
type Connection struct {
// contains filtered or unexported fields
}
func (*Connection) Close ¶
func (self *Connection) Close()
func (*Connection) Send ¶
func (self *Connection) Send(buf []byte) error
func (*Connection) Session ¶
func (self *Connection) Session() interface{}
func (*Connection) SetSession ¶ added in v0.0.2
func (self *Connection) SetSession(v interface{})
func (*Connection) Start ¶
func (self *Connection) Start()
type EmptyLogger ¶ added in v0.0.2
type EmptyLogger struct{}
func (EmptyLogger) Println ¶ added in v0.0.2
func (EmptyLogger) Println(v ...interface{})
type ErrorCommand ¶ added in v0.0.3
func ApiError ¶
func ApiError(typ, message string) *ErrorCommand
func (ErrorCommand) CmdName ¶ added in v0.0.3
func (ErrorCommand) CmdName() string
func (ErrorCommand) Error ¶ added in v0.0.3
func (e ErrorCommand) Error() string
type FakeConn ¶
type FakeConn struct { SessionValue interface{} Written [][]byte }
func NewFakeConn ¶
func NewFakeConn() *FakeConn
func (*FakeConn) SetSession ¶ added in v0.0.2
func (self *FakeConn) SetSession(v interface{})
type MiddlewareFunc ¶ added in v0.0.3
type PacketOut ¶
type PacketOut struct { Commands []CommandOut `json:"cmds"` Cid int32 `json:"cid,omitempty"` }
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) DescribeApi ¶
func (self *Router) DescribeApi(tm map[reflect.Type]string) (scmds []*ServerCommandDesciption, ccmds []*ClientCommandDesciption)
func (*Router) ProcessCommand ¶
func (self *Router) ProcessCommand(conn Conn, version int, command string, data json.RawMessage) (res []CommandOut)
func (*Router) ProcessPacket ¶
func (*Router) RegisterApiHandler ¶
handlerFunc Must be func(*Conn,*SomeType) *SomeRetType,error Or func(*Conn,*SomeType) *SomeRetType,*SomeOtherRetType,error Or func(*Conn,*SomeType) []interface{},error Or func(*Conn,*SomeType) error
func (*Router) RegisterApiHandlerWithMiddleware ¶ added in v0.0.3
func (self *Router) RegisterApiHandlerWithMiddleware(version int, command string, handler handlerFunc, middle []MiddlewareFunc)
func (*Router) RegisterGetVersion ¶
func (*Router) With ¶ added in v0.0.3
func (self *Router) With(mw MiddlewareFunc) *middlewareWrapper
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func NewServer ¶
func NewServer(opts ServerOpts) (*Server, error)
type ServerCommandDesciption ¶
type ServerOpts ¶ added in v0.0.2
Click to show internal directories.
Click to hide internal directories.