Documentation ¶
Index ¶
- Constants
- func Encode(msg *Message) ([]byte, error)
- type Conn
- type Message
- type Session
- func (s *Session) BindUserID(uid string)
- func (s *Session) GetConn() *Conn
- func (s *Session) GetSessionID() string
- func (s *Session) GetSetting(key string) interface{}
- func (s *Session) GetUserID() string
- func (s *Session) SetConn(conn *Conn)
- func (s *Session) SetSetting(key string, value interface{})
- type SocketService
- func (s *SocketService) Broadcast(msg *Message)
- func (s *SocketService) GetConnsCount() int
- func (s *SocketService) GetStatus() int
- func (s *SocketService) RegConnectHandler(handler func(*Session))
- func (s *SocketService) RegDisconnectHandler(handler func(*Session, error))
- func (s *SocketService) RegMessageHandler(handler func(*Session, *Message))
- func (s *SocketService) Serv()
- func (s *SocketService) SetHeartBeat(hbInterval time.Duration, hbTimeout time.Duration) error
- func (s *SocketService) Stop(reason string)
- func (s *SocketService) Unicast(sid string, msg *Message)
Constants ¶
View Source
const ( // STUnknown Unknown STUnknown = iota // STInited Inited STInited // STRunning Running STRunning // STStop Stop STStop )
View Source
const ( // MsgHeartbeat heartbeat MsgHeartbeat = iota )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn wrap net.Conn
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message struct
func NewMessage ¶
NewMessage create a new message
type Session ¶
type Session struct {
// contains filtered or unexported fields
}
Session struct
func (*Session) BindUserID ¶
BindUserID bind a user ID to session
func (*Session) GetSetting ¶
GetSetting get setting
func (*Session) SetSetting ¶
SetSetting set setting
type SocketService ¶
type SocketService struct {
// contains filtered or unexported fields
}
SocketService struct
func NewSocketService ¶
func NewSocketService(laddr string) (*SocketService, error)
NewSocketService create a new socket service
func (*SocketService) Broadcast ¶
func (s *SocketService) Broadcast(msg *Message)
Broadcast Broadcast to all connections
func (*SocketService) GetConnsCount ¶
func (s *SocketService) GetConnsCount() int
GetConnsCount get connect count
func (*SocketService) GetStatus ¶
func (s *SocketService) GetStatus() int
GetStatus get socket service status
func (*SocketService) RegConnectHandler ¶
func (s *SocketService) RegConnectHandler(handler func(*Session))
RegConnectHandler register connect handler
func (*SocketService) RegDisconnectHandler ¶
func (s *SocketService) RegDisconnectHandler(handler func(*Session, error))
RegDisconnectHandler register disconnect handler
func (*SocketService) RegMessageHandler ¶
func (s *SocketService) RegMessageHandler(handler func(*Session, *Message))
RegMessageHandler register message handler
func (*SocketService) SetHeartBeat ¶
SetHeartBeat set heart beat
func (*SocketService) Stop ¶
func (s *SocketService) Stop(reason string)
Stop stop socket service with reason
func (*SocketService) Unicast ¶
func (s *SocketService) Unicast(sid string, msg *Message)
Unicast Unicast with session ID
Click to show internal directories.
Click to hide internal directories.