Documentation ¶
Index ¶
- Variables
- func GetRelatedRoles(roleID string) []string
- func GetUserRoles(userID string) []string
- func PushError(ws *WebSocket, code int, errMsg string, reconnect bool)
- func RunWebSocketServer(pattern, addr string, h WebSocketHandler)
- func Validate(data t.M, op string) error
- type Client
- type SessionTokenCache
- type Subscription
- type SubscriptionInfo
- type WebSocket
- type WebSocketHandler
Constants ¶
This section is empty.
Variables ¶
View Source
var TomatoInfo = map[string]string{}
TomatoInfo ...
Functions ¶
func GetRelatedRoles ¶
func RunWebSocketServer ¶
func RunWebSocketServer(pattern, addr string, h WebSocketHandler)
RunWebSocketServer ...
Types ¶
type Client ¶
type Client struct { SubscriptionInfos map[int]*SubscriptionInfo PushConnect func(int, t.M, t.M) PushSubscribe func(int, t.M, t.M) PushUnsubscribe func(int, t.M, t.M) PushCreate func(int, t.M, t.M) PushEnter func(int, t.M, t.M) PushUpdate func(int, t.M, t.M) PushDelete func(int, t.M, t.M) PushLeave func(int, t.M, t.M) // contains filtered or unexported fields }
Client 客户端信息 ws 当前对象的 WebSocket 连接 SubscriptionInfos 当前客户端发起的所有请求对应的订阅信息
func (*Client) AddSubscriptionInfo ¶
func (c *Client) AddSubscriptionInfo(requestID int, subscriptionInfo *SubscriptionInfo)
AddSubscriptionInfo 添加 requestID 对应的订阅信息
func (*Client) DeleteSubscriptionInfo ¶
DeleteSubscriptionInfo 删除 requestID 对应的订阅信息
func (*Client) GetSubscriptionInfo ¶
func (c *Client) GetSubscriptionInfo(requestID int) *SubscriptionInfo
GetSubscriptionInfo 获取 requestID 对应的订阅信息
type SessionTokenCache ¶
type SessionTokenCache struct {
// contains filtered or unexported fields
}
SessionTokenCache 缓存 SessionToken 及其对应的用户 ID
func (*SessionTokenCache) GetUserID ¶
func (s *SessionTokenCache) GetUserID(sessionToken string) string
GetUserID 获取用户 ID
type Subscription ¶
Subscription 订阅对象 一组 ClassName Hash 对应唯一一个对象 ClientRequestIDs 记录连接到该对象的所有客户端
func NewSubscription ¶
func NewSubscription(className string, query t.M, queryHash string) *Subscription
NewSubscription ...
func (*Subscription) AddClientSubscription ¶
func (s *Subscription) AddClientSubscription(clientID, requestID int)
AddClientSubscription 添加连接到该订阅对象的客户端请求
func (*Subscription) DeleteClientSubscription ¶
func (s *Subscription) DeleteClientSubscription(clientID, requestID int)
DeleteClientSubscription 删除连接到该订阅对象的客户端请求
func (*Subscription) HasSubscribingClient ¶
func (s *Subscription) HasSubscribingClient() bool
HasSubscribingClient 返回连接到该对象的客户端数量
type SubscriptionInfo ¶
type SubscriptionInfo struct { Subscription *Subscription SessionToken string Fields []string }
SubscriptionInfo 订阅对象信息 每一个客户端请求对应一个对象
type WebSocket ¶
type WebSocket struct { ClientID int // contains filtered or unexported fields }
WebSocket ...
type WebSocketHandler ¶
type WebSocketHandler interface { OnConnect(ws *WebSocket) OnMessage(ws *WebSocket, msg interface{}) OnDisconnect(ws *WebSocket) }
WebSocketHandler ...
Click to show internal directories.
Click to hide internal directories.