Documentation ¶
Index ¶
- Constants
- Variables
- func DisableDebug()
- func EnableDebug()
- func SendError(model, action string, session Session, levelInt int, levelStr Level, ...)
- func SendMsg(model, action string, session Session, data map[string]interface{})
- func SosoWebsocketReceiver(rw http.ResponseWriter, req *http.Request, engine *Engine)
- type Engine
- type HandlerFunc
- type Level
- type Log
- type Msg
- type Request
- type Response
- type Route
- type Router
- func (r *Router) CREATE(model string, handler HandlerFunc)
- func (r *Router) DELETE(model string, handler HandlerFunc)
- func (r *Router) FLUSH(model string, handler HandlerFunc)
- func (r *Router) GET(model string, handler HandlerFunc)
- func (r *Router) Handle(model string, action string, handler HandlerFunc)
- func (r *Router) HandleList(routes []Route)
- func (r *Router) HandleRoutes(routes Routes)
- func (r *Router) SEARCH(model string, handler HandlerFunc)
- func (r *Router) UPDATE(model string, handler HandlerFunc)
- type Routes
- func (r *Routes) CREATE(model string, handler HandlerFunc)
- func (r *Routes) DELETE(model string, handler HandlerFunc)
- func (r *Routes) FLUSH(model string, handler HandlerFunc)
- func (r *Routes) GET(model string, handler HandlerFunc)
- func (r *Routes) Handle(model, action string, handler HandlerFunc)
- func (r *Routes) SEARCH(model string, handler HandlerFunc)
- func (r *Routes) UPDATE(model string, handler HandlerFunc)
- type Session
- type SessionList
- type SessionListImpl
- func (s *SessionListImpl) Get(uid string) []Session
- func (s *SessionListImpl) GetUID(session Session) (string, bool)
- func (s *SessionListImpl) OnClose(handler func(session Session))
- func (s *SessionListImpl) OnCloseExecute(session Session)
- func (s *SessionListImpl) OnOpen(handler func(session Session))
- func (s *SessionListImpl) OnOpenExecute(session Session)
- func (s *SessionListImpl) Pull(session Session) bool
- func (s *SessionListImpl) Push(session Session, uid string) int
- func (s *SessionListImpl) Size(uid string) int
- type User
Constants ¶
View Source
const (
Version string = "3.3.0"
)
Variables ¶
View Source
var ( WebSocketReadBufSize = 1024 WebSocketWriteBufSize = 1024 WriteWait = 10 * time.Second // Milliseconds until write times out. PongWait = 60 * time.Second // Timeout for waiting on pong. // Send pings to peer with this period. Must be less than pongWait. PingPeriod = (PongWait * 9) / 10 // Milliseconds between pings. MaxMessageSize int64 = 1024 * 1024 MessageBufferSize = 256 )
View Source
var (
LastLogID int = 1
)
View Source
var (
Loger = l.New()
)
View Source
var Sessions = NewSessionList()
Functions ¶
func DisableDebug ¶
func DisableDebug()
func EnableDebug ¶
func EnableDebug()
func SosoWebsocketReceiver ¶
func SosoWebsocketReceiver(rw http.ResponseWriter, req *http.Request, engine *Engine)
Types ¶
type HandlerFunc ¶
type HandlerFunc func(*Msg)
type Level ¶
type Level int64
const ( // System is unusable(Ex: This level should not be used by applications) LevelEmergency Level = iota // Should be corrected immediately(Ex: Loss of the primary ISP connection) LevelAlert // Critical conditions(Ex: A failure in the system's primary application) LevelCritical // Error conditions(Ex: An application has exceeded its file storage limit and attempts to write are failing) LevelError // May indicate that an error will occur if action is not taken (Ex: A non-root file system has only 2GB remaining) LevelWarning // Events that are unusual, but not error conditions. LevelNotice // Normal operation events that require no action (Ex: An application has started, paused or ended successfully. LevelInfo // Information useful to developers for debugging an application LevelDebug )
type Log ¶
type Msg ¶
type Request ¶
type Request struct { Action string `json:"action"` Model string `json:"model"` Log Log `json:"log"` Data *json.RawMessage `json:"data"` Other *json.RawMessage `json:"other"` }
Request
func NewRequest ¶
type Response ¶
type Response struct { Model string `json:"model"` Action string `json:"action"` Data interface{} `json:"data"` Log Log `json:"log"` Other interface{} `json:"other"` }
direct and indirect responses
func NewResponse ¶
type Route ¶
type Route struct { Model string Action string Handler HandlerFunc }
type Router ¶
func (*Router) CREATE ¶
func (r *Router) CREATE(model string, handler HandlerFunc)
func (*Router) DELETE ¶
func (r *Router) DELETE(model string, handler HandlerFunc)
func (*Router) FLUSH ¶
func (r *Router) FLUSH(model string, handler HandlerFunc)
func (*Router) GET ¶
func (r *Router) GET(model string, handler HandlerFunc)
func (*Router) HandleList ¶
func (*Router) HandleRoutes ¶
func (*Router) SEARCH ¶
func (r *Router) SEARCH(model string, handler HandlerFunc)
func (*Router) UPDATE ¶
func (r *Router) UPDATE(model string, handler HandlerFunc)
type Routes ¶
type Routes struct {
List []Route
}
func (*Routes) CREATE ¶
func (r *Routes) CREATE(model string, handler HandlerFunc)
func (*Routes) DELETE ¶
func (r *Routes) DELETE(model string, handler HandlerFunc)
func (*Routes) FLUSH ¶
func (r *Routes) FLUSH(model string, handler HandlerFunc)
func (*Routes) GET ¶
func (r *Routes) GET(model string, handler HandlerFunc)
func (*Routes) Handle ¶
func (r *Routes) Handle(model, action string, handler HandlerFunc)
func (*Routes) SEARCH ¶
func (r *Routes) SEARCH(model string, handler HandlerFunc)
func (*Routes) UPDATE ¶
func (r *Routes) UPDATE(model string, handler HandlerFunc)
type Session ¶
type Session interface { // Id returns a session id ID() string // Recv reads one text frame from session Recv() ([]byte, error) // Send sends one text frame to session Send(string) error // Close closes the session with provided code and reason. Close(status uint32, reason string) error IsClosed() bool }
type SessionList ¶
type SessionList interface { // Push adds session to collection Push(session Session, uid string) int // Get retries all active sessions for the user Get(uid string) []Session // Get UID - user id by session GetUID(session Session) (uid string, exists bool) // Pull removes session object from collection Pull(session Session) bool // Size returns count of active sessions Size(uid string) int // OnOpen handler at init new session OnOpen(func(Session)) // OnClose handler at close session OnClose(func(Session)) // OnOpenExecute fire it if session open // Automatical if used Router.Sessions OnOpenExecute(Session) // OnCloseExecute fire it if session close // Automatical if used Router.Sessions OnCloseExecute(Session) }
func NewSessionList ¶
func NewSessionList() SessionList
type SessionListImpl ¶
func (*SessionListImpl) Get ¶
func (s *SessionListImpl) Get(uid string) []Session
func (*SessionListImpl) OnClose ¶
func (s *SessionListImpl) OnClose(handler func(session Session))
func (*SessionListImpl) OnCloseExecute ¶
func (s *SessionListImpl) OnCloseExecute(session Session)
OnCloseExecute Execute close handler and pull session from list Use if custom SessionList
func (*SessionListImpl) OnOpen ¶
func (s *SessionListImpl) OnOpen(handler func(session Session))
func (*SessionListImpl) OnOpenExecute ¶
func (s *SessionListImpl) OnOpenExecute(session Session)
OnOpenExecute Execute open handler Use if custom SessionList
func (*SessionListImpl) Pull ¶
func (s *SessionListImpl) Pull(session Session) bool
func (*SessionListImpl) Size ¶
func (s *SessionListImpl) Size(uid string) int
Source Files ¶
Click to show internal directories.
Click to hide internal directories.