Documentation ¶
Index ¶
- Constants
- Variables
- func NewSessionID() string
- func StackTrace(all bool) string
- type Broadcaster
- type Config
- type Event
- type EventEmitter
- type MessageType
- type MovingAverage
- type NameSpace
- func (ns *NameSpace) Call(name string, timeout time.Duration, reply []interface{}, args ...interface{}) error
- func (ns *NameSpace) Emit(name string, args ...interface{}) error
- func (ns *NameSpace) Endpoint() string
- func (ns *NameSpace) Id() string
- func (ns *NameSpace) Send(message interface{}) error
- type Packet
- type Session
- func (ss *Session) Close(params ...interface{}) error
- func (ss *Session) Closed() bool
- func (ss *Session) Flush() error
- func (ss *Session) Less(b *Session) bool
- func (ss *Session) Of(name string) (nameSpace *NameSpace)
- func (ss *Session) RawMessage(msg []byte) error
- func (ss *Session) RemoveHandler(h SessionHandler) bool
- func (ss *Session) Send(data []byte) error
- func (ss *Session) SetHandler(h SessionHandler) bool
- type SessionContainer
- type SessionHandler
- type SocketIOServer
- func (srv *SocketIOServer) Broadcast(name string, args ...interface{})
- func (srv *SocketIOServer) Except(ns *NameSpace) *Broadcaster
- func (srv *SocketIOServer) In(name string) *Broadcaster
- func (srv *SocketIOServer) Of(name string) *EventEmitter
- func (srv *SocketIOServer) On(name string, fn interface{}) error
- func (srv *SocketIOServer) RemoveAllListeners(name string)
- func (srv *SocketIOServer) RemoveListener(name string, fn interface{})
- func (srv *SocketIOServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (srv *SocketIOServer) Sessions() *SessionContainer
- type StatsCollector
- func (s *StatsCollector) ConnectionClosed()
- func (s *StatsCollector) ConnectionOpened()
- func (s *StatsCollector) Dump() *StatsResult
- func (s *StatsCollector) OnPacketRecv(num int)
- func (s *StatsCollector) OnPacketSent(num int)
- func (s *StatsCollector) SessionClosed()
- func (s *StatsCollector) SessionOpened()
- func (s *StatsCollector) Start()
- type StatsResult
- type Transport
- type TransportManager
Constants ¶
View Source
const ( PACKET_DISCONNECT = iota PACKET_CONNECT PACKET_HEARTBEAT PACKET_MESSAGE PACKET_JSONMESSAGE PACKET_EVENT PACKET_ACK PACKET_ERROR PACKET_NOOP )
View Source
const ( SessionIDLength = 32 SessionIDCharset = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" )
Variables ¶
View Source
var ClosingError = errors.New("Handler Closing")
View Source
var (
DefaultTransports = NewTransportManager()
)
View Source
var NotConnected = errors.New("not connected")
Functions ¶
func NewSessionID ¶
func NewSessionID() string
func StackTrace ¶
Types ¶
type Broadcaster ¶
type Broadcaster struct {
Namespaces []*NameSpace
}
func (*Broadcaster) Broadcast ¶
func (b *Broadcaster) Broadcast(name string, args ...interface{})
func (*Broadcaster) Except ¶
func (b *Broadcaster) Except(namespace *NameSpace) *Broadcaster
type Config ¶
type Config struct { ResourceName string //命名空间 HeartbeatInterval int //心跳时间 SessionExpiry int //session 有效时间 SessionCheckInterval int //session 检查间隔 PollingTimeout int //polling 超时时间 ClosingTimeout int NewSessionID func() string Transports *TransportManager Authorize func(*http.Request, map[interface{}]interface{}) bool }
type Event ¶
type Event struct { Name string `json:"name"` Args json.RawMessage `json:"args"` }
type EventEmitter ¶
type EventEmitter struct {
// contains filtered or unexported fields
}
func NewEventEmitter ¶
func NewEventEmitter() *EventEmitter
func (*EventEmitter) On ¶
func (ee *EventEmitter) On(name string, fn interface{}) error
func (*EventEmitter) RemoveAllListeners ¶
func (ee *EventEmitter) RemoveAllListeners(name string)
func (*EventEmitter) RemoveListener ¶
func (ee *EventEmitter) RemoveListener(name string, fn interface{})
type MessageType ¶
type MessageType uint8
type MovingAverage ¶
type MovingAverage struct {
// contains filtered or unexported fields
}
func NewMovingAverage ¶
func NewMovingAverage(period int) *MovingAverage
type NameSpace ¶
type NameSpace struct { *EventEmitter Session *Session // contains filtered or unexported fields }
func NewNameSpace ¶
func NewNameSpace(session *Session, endpoint string, ee *EventEmitter) *NameSpace
type Session ¶
type Session struct { sync.Mutex SessionId string Values map[interface{}]interface{} Request *http.Request SendBuffer [][]byte // contains filtered or unexported fields }
func NewSession ¶
func NewSession(sessionId string, srv *SocketIOServer, r *http.Request) *Session
func (*Session) RawMessage ¶
func (*Session) RemoveHandler ¶
func (ss *Session) RemoveHandler(h SessionHandler) bool
func (*Session) SetHandler ¶
func (ss *Session) SetHandler(h SessionHandler) bool
type SessionContainer ¶
type SessionContainer struct {
// contains filtered or unexported fields
}
func NewSessionContainer ¶
func NewSessionContainer() *SessionContainer
func (*SessionContainer) Add ¶
func (s *SessionContainer) Add(ss *Session)
func (*SessionContainer) Expire ¶
func (s *SessionContainer) Expire()
func (*SessionContainer) Get ¶
func (s *SessionContainer) Get(sessionId string) *Session
func (*SessionContainer) Range ¶
func (s *SessionContainer) Range() map[string]*Session
func (*SessionContainer) Remove ¶
func (s *SessionContainer) Remove(ss *Session)
type SessionHandler ¶
type SocketIOServer ¶
type SocketIOServer struct { *http.ServeMux Config *Config Stats *StatsCollector // contains filtered or unexported fields }
func NewSocketIOServer ¶
func NewSocketIOServer(config *Config) *SocketIOServer
func (*SocketIOServer) Broadcast ¶
func (srv *SocketIOServer) Broadcast(name string, args ...interface{})
func (*SocketIOServer) Except ¶
func (srv *SocketIOServer) Except(ns *NameSpace) *Broadcaster
func (*SocketIOServer) In ¶
func (srv *SocketIOServer) In(name string) *Broadcaster
func (*SocketIOServer) Of ¶
func (srv *SocketIOServer) Of(name string) *EventEmitter
func (*SocketIOServer) On ¶
func (srv *SocketIOServer) On(name string, fn interface{}) error
func (*SocketIOServer) RemoveAllListeners ¶
func (srv *SocketIOServer) RemoveAllListeners(name string)
func (*SocketIOServer) RemoveListener ¶
func (srv *SocketIOServer) RemoveListener(name string, fn interface{})
func (*SocketIOServer) ServeHTTP ¶
func (srv *SocketIOServer) ServeHTTP(w http.ResponseWriter, r *http.Request)
func (*SocketIOServer) Sessions ¶
func (srv *SocketIOServer) Sessions() *SessionContainer
type StatsCollector ¶
type StatsCollector struct { StartTime time.Time MaxSession int64 ActiveSession int64 MaxConnections float64 ActiveConnections float64 ConnectionsPs *MovingAverage PacketsSentPs *MovingAverage PacketsRecvPs *MovingAverage // contains filtered or unexported fields }
func NewStatsCollector ¶
func NewStatsCollector() *StatsCollector
func (*StatsCollector) ConnectionClosed ¶
func (s *StatsCollector) ConnectionClosed()
func (*StatsCollector) ConnectionOpened ¶
func (s *StatsCollector) ConnectionOpened()
func (*StatsCollector) Dump ¶
func (s *StatsCollector) Dump() *StatsResult
func (*StatsCollector) OnPacketRecv ¶
func (s *StatsCollector) OnPacketRecv(num int)
func (*StatsCollector) OnPacketSent ¶
func (s *StatsCollector) OnPacketSent(num int)
func (*StatsCollector) SessionClosed ¶
func (s *StatsCollector) SessionClosed()
func (*StatsCollector) SessionOpened ¶
func (s *StatsCollector) SessionOpened()
func (*StatsCollector) Start ¶
func (s *StatsCollector) Start()
type StatsResult ¶
type TransportManager ¶
type TransportManager struct {
// contains filtered or unexported fields
}
func NewTransportManager ¶
func NewTransportManager() *TransportManager
func (*TransportManager) GetTransportNames ¶
func (tm *TransportManager) GetTransportNames() (names []string)
func (*TransportManager) RegisterTransport ¶
func (tm *TransportManager) RegisterTransport(name string)
Source Files ¶
Click to show internal directories.
Click to hide internal directories.