Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func OnAfterSessionBind ¶
OnAfterSessionBind adds a method to be called when session is bound and after all sessionBind callbacks
func OnSessionBind ¶
OnSessionBind adds a method to be called when a session is bound same function cannot be added twice!
func OnSessionClose ¶
func OnSessionClose(f func(s Session))
OnSessionClose adds a method that will be called when every session closes
Types ¶
type HandshakeClientData ¶
type HandshakeClientData struct {
Platform string `json:"platform"`
LibVersion string `json:"libVersion"`
BuildNumber string `json:"clientBuildNumber"`
Version string `json:"clientVersion"`
}
HandshakeClientData represents information about the client sent on the handshake.
type HandshakeData ¶
type HandshakeData struct {
Sys HandshakeClientData `json:"sys"`
User map[string]interface{} `json:"user,omitempty"`
}
HandshakeData represents information about the handshake sent by the client. `sys` corresponds to information independent from the app and `user` information that depends on the app and is customized by the user.
type ReqInFlight ¶
type ReqInFlight struct {
// contains filtered or unexported fields
}
type Session ¶
type Session interface {
GetOnCloseCallbacks() []func()
GetIsFrontend() bool
GetSubscriptions() []*nats.Subscription
SetOnCloseCallbacks(callbacks []func())
SetIsFrontend(isFrontend bool)
SetSubscriptions(subscriptions []*nats.Subscription)
HasRequestsInFlight() bool
GetRequestsInFlight() ReqInFlight
SetRequestInFlight(reqID string, reqData string, inFlight bool)
Push(route string, v interface{}) error
ResponseMID(ctx context.Context, mid uint, v interface{}, err ...bool) error
ResponseRoute(ctx context.Context, mid uint, route string, v interface{}, err ...bool) error
ID() int64
UID() string
GetData() map[string]interface{}
SetData(data map[string]interface{}) error
GetDataEncoded() []byte
SetDataEncoded(encodedData []byte) error
SetFrontendData(frontendID string, frontendSessionID int64)
Bind(ctx context.Context, uid string) error
Kick(ctx context.Context) error
OnClose(c func()) error
Close()
RemoteAddr() net.Addr
Remove(key string) error
Set(key string, value interface{}) error
HasKey(key string) bool
Get(key string) interface{}
Int(key string) int
Int8(key string) int8
Int16(key string) int16
Int32(key string) int32
Int64(key string) int64
Uint(key string) uint
Uint8(key string) uint8
Uint16(key string) uint16
Uint32(key string) uint32
Uint64(key string) uint64
Float32(key string) float32
Float64(key string) float64
String(key string) string
Value(key string) interface{}
PushToFront(ctx context.Context) error
Clear()
SetHandshakeData(data *HandshakeData)
GetHandshakeData() *HandshakeData
ValidateHandshake(data *HandshakeData) error
GetHandshakeValidators() map[string]func(data *HandshakeData) error
}
Session represents a client session, which can store data during the connection. All data is released when the low-level connection is broken. Session instance related to the client will be passed to Handler method in the context parameter.
func GetSessionByID ¶
GetSessionByID return a session bound to a frontend server id
func GetSessionByUID ¶
GetSessionByUID return a session bound to an user id
type SessionPool ¶
type SessionPool interface {
NewSession(entity networkentity.NetworkEntity, frontend bool, UID ...string) Session
GetSessionCount() int64
GetSessionCloseCallbacks() []func(s Session)
GetSessionByUID(uid string) Session
GetSessionByID(id int64) Session
OnSessionBind(f func(ctx context.Context, s Session) error)
OnAfterSessionBind(f func(ctx context.Context, s Session) error)
OnSessionClose(f func(s Session))
CloseAll()
AddHandshakeValidator(name string, f func(data *HandshakeData) error)
}
SessionPool centralizes all sessions within a Pitaya app
var DefaultSessionPool SessionPool
func NewSessionPool ¶
func NewSessionPool() SessionPool
NewSessionPool returns a new session pool instance