Documentation ¶
Index ¶
- Variables
- func EnableDebug()
- func Invoke(fn func())
- func Listen(addr string)
- func ListenWS(addr string)
- func OnSessionClosed(cb SessionClosedHandler)
- func Register(c component.Component, options ...component.Option)
- func SetCheckOriginFunc(fn func(*http.Request) bool)
- func SetDictionary(dict map[string]uint16)
- func SetHeartbeatInterval(d time.Duration)
- func SetLogger(l Logger)
- func SetSerializer(seri serialize.Serializer)
- func SetTimerBacklog(c int)
- func SetTimerPrecision(precision time.Duration)
- func SetWSPath(path string)
- func Shutdown()
- type Group
- func (c *Group) Add(session *session.Session) error
- func (c *Group) Broadcast(route string, v interface{}) error
- func (c *Group) Close() error
- func (c *Group) Contains(uid int64) bool
- func (c *Group) Count() int
- func (c *Group) Leave(s *session.Session) error
- func (c *Group) LeaveAll() error
- func (c *Group) Member(uid int64) (*session.Session, error)
- func (c *Group) Members() []int64
- func (c *Group) Multicast(route string, v interface{}, filter SessionFilter) error
- type Logger
- type SessionClosedHandler
- type SessionFilter
- type Timer
- type TimerCondition
- type TimerFunc
Constants ¶
This section is empty.
Variables ¶
var ( // ErrBrokenPipe represents the low-level connection has broken. ErrBrokenPipe = errors.New("broken low-level pipe") // ErrBufferExceed indicates that the current session buffer is full and // can not receive more data. ErrBufferExceed = errors.New("session send buffer exceed") )
var ( ErrSessionOnNotify = errors.New("current session working on notify mode") ErrCloseClosedGroup = errors.New("close closed group") ErrClosedGroup = errors.New("group closed") ErrMemberNotFound = errors.New("member not found in the group") ErrCloseClosedSession = errors.New("close closed session") ErrSessionDuplication = errors.New("session has existed in the current group") )
Errors that could be occurred during message handling.
var Pipeline = struct {
Outbound, Inbound *pipelineChannel
}{&pipelineChannel{}, &pipelineChannel{}}
var VERSION = "0.0.1"
VERSION returns current nano version
Functions ¶
func Listen ¶
func Listen(addr string)
Listen listens on the TCP network address addr and then calls Serve with handler to handle requests on incoming connections.
func ListenWS ¶
func ListenWS(addr string)
ListenWS listens on the TCP network address addr and then upgrades the HTTP server connection to the WebSocket protocol to handle requests on incoming connections.
func OnSessionClosed ¶
func OnSessionClosed(cb SessionClosedHandler)
OnSessionClosed set the Callback which will be called when session is closed Waring: session has closed,
func SetCheckOriginFunc ¶
SetCheckOriginFunc set the function that check `Origin` in http headers
func SetDictionary ¶
SetDictionary set routes map, TODO(warning): set dictionary in runtime would be a dangerous operation!!!!!!
func SetHeartbeatInterval ¶
SetHeartbeatInterval set heartbeat time interval
func SetSerializer ¶
func SetSerializer(seri serialize.Serializer)
SetSerializer customize application serializer, which automatically Marshal and UnMarshal handler payload
func SetTimerBacklog ¶
func SetTimerBacklog(c int)
SetTimerBacklog set the timer created/closing channel backlog, A small backlog may cause the logic to be blocked when call NewTimer/NewCountTimer/timer.Stop in main logic gorontine.
func SetTimerPrecision ¶
SetTimerPrecision set the ticker precision, and time precision can not less than a Millisecond, and can not change after application running. The default precision is time.Second
Types ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group represents a session group which used to manage a number of sessions, data send to the group will send to all session in it.
type Logger ¶
type Logger interface { Println(v ...interface{}) Fatal(v ...interface{}) }
Logger represents the log interface
type SessionClosedHandler ¶
SessionClosedHandler represents a callback that will be called when a session close or session low-level connection broken.
type SessionFilter ¶
SessionFilter represents a filter which was used to filter session when Multicast, the session will receive the message while filter returns true.
type Timer ¶
type Timer struct {
// contains filtered or unexported fields
}
Timer represents a cron job
func NewAfterTimer ¶
NewAfterTimer returns a new Timer containing a function that will be called after duration that specified by the duration argument. The duration d must be greater than zero; if not, NewAfterTimer will panic. Stop the timer to release associated resources.
func NewCondTimer ¶
func NewCondTimer(condition TimerCondition, fn TimerFunc) *Timer
NewCondTimer returns a new Timer containing a function that will be called when condition satisfied that specified by the condition argument. The duration d must be greater than zero; if not, NewCondTimer will panic. Stop the timer to release associated resources.
func NewCountTimer ¶
NewCountTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. After count times, timer will be stopped automatically, It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewCountTimer will panic. Stop the timer to release associated resources.
func NewTimer ¶
NewTimer returns a new Timer containing a function that will be called with a period specified by the duration argument. It adjusts the intervals for slow receivers. The duration d must be greater than zero; if not, NewTimer will panic. Stop the timer to release associated resources.
type TimerCondition ¶
TimerCondition represents a checker that returns true when cron job needs to execute