Documentation ¶
Index ¶
- Variables
- func BroadcastData(users []string, data []byte, filter *session.SessionFilter, exclude ...string)
- func BroadcastMessage(users []string, send interface{}, filter *session.SessionFilter, ...) error
- func EncodeMessage(in interface{}, name ...string) (*packet.Packet, error)
- func GetSessionByID(id int64) (*session.Session, error)
- func GetSessionByUID(uid string, filter *session.SessionFilter) []*session.Session
- func GetSessionIDsByUID(uid string, filter *session.SessionFilter) ([]int64, []int64)
- func ListSessions() []*session.Session
- func NewBuilder(config *config.Config) *builder
- func SendDataByID(sessionId int64, in []byte)
- func SendMessageByID(sessionId int64, in interface{})
- func SendPacketByID(sessionId int64, in *packet.Packet)
- type App
- func (app *App) AddAcceptor(acceptor acceptor.Acceptor)
- func (app *App) GetAcceptors() []acceptor.Acceptor
- func (app *App) GetSessionPool() session.SessionPool
- func (app *App) RegisterComponent(sd component.ComponentDesc, ss interface{})
- func (app *App) RegisterWebHandler(port int, f func(gin *gin.Engine))
- func (app *App) SetAgentFactory(factory *agent.AgentFactory)
- func (app *App) Shutdown()
- func (app *App) Start()
- func (app *App) UseDefaultEncodeJSON()
- func (app *App) UseDefaultEncodeProto()
- func (app *App) UseDefaultEncodePureJSON()
- type NetworkComponent
Constants ¶
This section is empty.
Variables ¶
View Source
var DefaultMessageServer *message.MessageServer
View Source
var DefaultSessionPool session.SessionPool
View Source
var Version string
Functions ¶
func BroadcastData ¶ added in v0.1.6
func BroadcastData(users []string, data []byte, filter *session.SessionFilter, exclude ...string)
send bytes
func BroadcastMessage ¶ added in v0.1.6
func BroadcastMessage(users []string, send interface{}, filter *session.SessionFilter, exclude ...string) error
BroadcastMessage broadcast message to all sessions except the session with the given id. the filter is used to filter the sessions that should not receive the message. send packet
func EncodeMessage ¶ added in v0.1.6
func GetSessionByUID ¶ added in v0.1.6
func GetSessionByUID(uid string, filter *session.SessionFilter) []*session.Session
GetSessionByUID get session by user id.
func GetSessionIDsByUID ¶ added in v0.2.6
func GetSessionIDsByUID(uid string, filter *session.SessionFilter) ([]int64, []int64)
GetSessionIDsByUID get session by user id. the filter is used to filter the sessions that should not receive the message. result first is the session ids that match the filter, result second is the all session ids with the given uid.
func ListSessions ¶ added in v0.1.6
func NewBuilder ¶
func SendDataByID ¶ added in v0.1.6
func SendMessageByID ¶ added in v0.1.6
func SendMessageByID(sessionId int64, in interface{})
SendMessageByID send message to the session with the given id.
func SendPacketByID ¶ added in v0.1.6
Types ¶
type App ¶
type App struct { *zap.Logger MessageServer *message.MessageServer // 消息管理 LatencyServer *latency.LatencyServer // 延时服务管理 GroupServer *group.GroupServer // 组管理 Config *config.Config // contains filtered or unexported fields }
func (*App) AddAcceptor ¶
func (*App) GetAcceptors ¶
func (*App) GetSessionPool ¶
func (app *App) GetSessionPool() session.SessionPool
func (*App) RegisterComponent ¶
func (app *App) RegisterComponent(sd component.ComponentDesc, ss interface{})
func (*App) RegisterWebHandler ¶
func (*App) SetAgentFactory ¶
func (app *App) SetAgentFactory(factory *agent.AgentFactory)
func (*App) UseDefaultEncodeJSON ¶
func (app *App) UseDefaultEncodeJSON()
func (*App) UseDefaultEncodeProto ¶
func (app *App) UseDefaultEncodeProto()
func (*App) UseDefaultEncodePureJSON ¶ added in v0.3.1
func (app *App) UseDefaultEncodePureJSON()
UseDefaultEncodePureJSON 发送消息时不包含头部,使用JSON,方便测试使用,纯JSON 编码有两种,一种是带头部的,一种是不带头部的 PureJSON是不带头部的,类型是写在action里面的
type NetworkComponent ¶
type NetworkComponent struct {
// contains filtered or unexported fields
}
func NewNetworkComponent ¶
func NewNetworkComponent(app *App) *NetworkComponent
Click to show internal directories.
Click to hide internal directories.