Documentation ¶
Index ¶
- Constants
- func KickClient(hub *Hub, client *Client)
- type Broadcast
- type Client
- type ComponentAttachedUsers
- type Feedback
- type Hub
- func (hub *Hub) BroadcastToGlobal(message *Message, currentClient *Client, includeCurrentClient bool)
- func (hub *Hub) BroadcastToOtherClients(message *Message, currentClient *Client)
- func (hub *Hub) BroadcastToRoomAllClients(message *Message, currentClient *Client)
- func (hub *Hub) GetInRoomUsersByRoomID(roomID int) *InRoomUsers
- func (hub *Hub) SetAppServiceImpl(asi *app.AppServiceImpl)
- func (hub *Hub) SetAuthenticatorImpl(ai *user.AuthenticatorImpl)
- func (hub *Hub) SetKVStateServiceImpl(kvssi *state.KVStateServiceImpl)
- func (hub *Hub) SetResourceServiceImpl(rsi *resource.ResourceServiceImpl)
- func (hub *Hub) SetSetStateServiceImpl(sssi *state.SetStateServiceImpl)
- func (hub *Hub) SetTreeStateServiceImpl(tssi *state.TreeStateServiceImpl)
- type InRoomUsers
- func (iru *InRoomUsers) AttachComponent(userID int, componentDisplayNames []string)
- func (iru *InRoomUsers) DisattachComponent(userID int, componentDisplayNames []string)
- func (iru *InRoomUsers) EnterRoom(user *repository.User)
- func (iru *InRoomUsers) FetchAllAttachedUsers() *ComponentAttachedUsers
- func (iru *InRoomUsers) FetchAllInRoomUsers() *InRoomUsersFeedback
- func (iru *InRoomUsers) LeaveRoom(userID int)
- type InRoomUsersFeedback
- type Message
- type UserForCooperateFeedback
Constants ¶
View Source
const BROADCAST_TYPE_ATTACH_COMPONENT = "attachComponent"
View Source
const BROADCAST_TYPE_ENTER = "enter"
View Source
const BROADCAST_TYPE_SUFFIX = "/remote"
for broadcast rewrite
View Source
const DASHBOARD_APP_ID = -1
View Source
const DEFAULT_APP_ID = 0
View Source
const DEFAULT_INSTANCE_ID = "SELF_HOST"
View Source
const DEFAULT_ROOM_SLOT = 0
View Source
const ERROR_CAN_NOT_MOVE_KVSTATE = 10
View Source
const ERROR_CAN_NOT_MOVE_SETSTATE = 11
View Source
const ERROR_CODE_BROADCAST = 0
View Source
const ERROR_CODE_FAILED = 1
View Source
const ERROR_CODE_LOGGEDIN = 0
View Source
const ERROR_CODE_LOGIN_FAILED = 4
View Source
const ERROR_CODE_NEED_ENTER = 2
View Source
const ERROR_CODE_OK = 0
for feedback
View Source
const ERROR_CODE_PONG = 3
View Source
const ERROR_CREATE_OR_UPDATE_STATE_FAILED = 9
View Source
const ERROR_CREATE_OR_UPDATE_STATE_OK = 0
View Source
const ERROR_CREATE_STATE_FAILED = 5
View Source
const ERROR_CREATE_STATE_OK = 0
View Source
const ERROR_DELETE_STATE_FAILED = 6
View Source
const ERROR_DELETE_STATE_OK = 0
View Source
const ERROR_MOVE_STATE_FAILED = 8
View Source
const ERROR_MOVE_STATE_OK = 0
View Source
const ERROR_UPDATE_STATE_FAILED = 7
View Source
const ERROR_UPDATE_STATE_OK = 0
View Source
const OPTION_BROADCAST_ROOM = 1 // 00000000000000000000000000000001; // use as signed int32 in typescript
View Source
const SIGNAL_BROADCAST_ONLY = 8
View Source
const SIGNAL_COOPERATE_ATTACH = 11
View Source
const SIGNAL_COOPERATE_DISATTACH = 12
View Source
const SIGNAL_CREATE_OR_UPDATE_STATE = 7
View Source
const SIGNAL_CREATE_STATE = 3
View Source
const SIGNAL_DELETE_STATE = 4
View Source
const SIGNAL_ENTER = 1
View Source
const SIGNAL_GLOBAL_BROADCAST_ONLY = 10
View Source
const SIGNAL_LEAVE = 2
View Source
const SIGNAL_MOVE_STATE = 6
View Source
const SIGNAL_PING = 0
for message
View Source
const SIGNAL_PUT_STATE = 9
View Source
const SIGNAL_UPDATE_STATE = 5
View Source
const TARGET_ACTION = 8 // only for broadcast
View Source
const TARGET_APPS = 6 // only for broadcast
View Source
const TARGET_COMPONENTS = 1 // ComponentsState
View Source
const TARGET_DEPENDENCIES = 2 // DependenciesState
View Source
const TARGET_DISPLAY_NAME = 5 // DisplayNameState
View Source
const TARGET_DOTTED_LINE_SQUARE = 4 // DottedLineSquareState
View Source
const TARGET_DRAG_SHADOW = 3 // DragShadowState
View Source
const TARGET_NOTNING = 0 // placeholder for nothing
View Source
const TARGET_RESOURCE = 7 // only for broadcast
Variables ¶
This section is empty.
Functions ¶
func KickClient ¶
Types ¶
type Broadcast ¶
type Broadcast struct { Type string `json:"type"` Payload interface{} `json:"payload"` }
type Client ¶
type Client struct { ID uuid.UUID MappedUserID int IsLoggedIn bool Hub *Hub // The websocket connection. Conn *websocket.Conn // Buffered channel of outbound messages. Send chan []byte // instanceID, SELF_HOST by default InstanceID string // appID, 0 by default, -1 for dashboard APPID int }
Client is a middleman between the websocket connection and the hub.
func (*Client) ReadPump ¶
func (c *Client) ReadPump()
readPump pumps messages from the websocket connection to the hub.
The application runs readPump in a per-connection goroutine. The application ensures that there is at most one reader on a connection by executing all reads from this goroutine.
func (*Client) WritePump ¶
func (c *Client) WritePump()
writePump pumps messages from the hub to the websocket connection.
A goroutine running writePump is started for each connection. The application ensures that there is at most one writer to a connection by executing all writes from this goroutine.
type ComponentAttachedUsers ¶ added in v1.7.1
type ComponentAttachedUsers struct {
ComponentAttachedUsers map[string][]*UserForCooperateFeedback `json:"componentAttachedUsers"`
}
type Feedback ¶
type Feedback struct { ErrorCode int `json:"errorCode"` ErrorMessage string `json:"errorMessage"` Broadcast *Broadcast `json:"broadcast"` Data interface{} `json:"data"` }
func (*Feedback) Serialization ¶
type Hub ¶
type Hub struct { // registered clients map Clients map[uuid.UUID]*Client // inbound messages from the clients. // try “`hub.Broadcast <- []byte(message)“` Broadcast chan []byte // on message process OnMessage chan *Message // register requests from the clients. Register chan *Client // unregister requests from the clients. Unregister chan *Client // InRoomUsers InRoomUsersMap map[int]*InRoomUsers // map[roomID]*InRoomUsers // impl TreeStateServiceImpl *state.TreeStateServiceImpl KVStateServiceImpl *state.KVStateServiceImpl SetStateServiceImpl *state.SetStateServiceImpl AppServiceImpl *app.AppServiceImpl ResourceServiceImpl *resource.ResourceServiceImpl AuthenticatorImpl *user.AuthenticatorImpl }
clients hub, maintains active clients and broadcast messags.
func (*Hub) BroadcastToGlobal ¶
func (*Hub) BroadcastToOtherClients ¶
func (*Hub) BroadcastToRoomAllClients ¶ added in v1.7.1
func (*Hub) GetInRoomUsersByRoomID ¶ added in v1.7.1
func (hub *Hub) GetInRoomUsersByRoomID(roomID int) *InRoomUsers
func (*Hub) SetAppServiceImpl ¶
func (hub *Hub) SetAppServiceImpl(asi *app.AppServiceImpl)
func (*Hub) SetAuthenticatorImpl ¶
func (hub *Hub) SetAuthenticatorImpl(ai *user.AuthenticatorImpl)
func (*Hub) SetKVStateServiceImpl ¶
func (hub *Hub) SetKVStateServiceImpl(kvssi *state.KVStateServiceImpl)
func (*Hub) SetResourceServiceImpl ¶
func (hub *Hub) SetResourceServiceImpl(rsi *resource.ResourceServiceImpl)
func (*Hub) SetSetStateServiceImpl ¶
func (hub *Hub) SetSetStateServiceImpl(sssi *state.SetStateServiceImpl)
func (*Hub) SetTreeStateServiceImpl ¶
func (hub *Hub) SetTreeStateServiceImpl(tssi *state.TreeStateServiceImpl)
type InRoomUsers ¶ added in v1.7.1
type InRoomUsers struct { RoomID int All []*UserForCooperateFeedback // []*UserForCooperateFeedback AllUsers map[int]*UserForCooperateFeedback // map[user.ID]*UserForCooperateFeedback AttachedUserList map[string][]*UserForCooperateFeedback // map[component.DisplayName][]*UserForCooperateFeedback }
func NewInRoomUsers ¶ added in v1.7.1
func NewInRoomUsers(roomID int) *InRoomUsers
func (*InRoomUsers) AttachComponent ¶ added in v1.7.1
func (iru *InRoomUsers) AttachComponent(userID int, componentDisplayNames []string)
func (*InRoomUsers) DisattachComponent ¶ added in v1.7.1
func (iru *InRoomUsers) DisattachComponent(userID int, componentDisplayNames []string)
func (*InRoomUsers) EnterRoom ¶ added in v1.7.1
func (iru *InRoomUsers) EnterRoom(user *repository.User)
func (*InRoomUsers) FetchAllAttachedUsers ¶ added in v1.7.1
func (iru *InRoomUsers) FetchAllAttachedUsers() *ComponentAttachedUsers
func (*InRoomUsers) FetchAllInRoomUsers ¶ added in v1.7.1
func (iru *InRoomUsers) FetchAllInRoomUsers() *InRoomUsersFeedback
func (*InRoomUsers) LeaveRoom ¶ added in v1.7.1
func (iru *InRoomUsers) LeaveRoom(userID int)
type InRoomUsersFeedback ¶ added in v1.7.1
type InRoomUsersFeedback struct {
InRoomUsers []*UserForCooperateFeedback `json:"inRoomUsers"`
}
type Message ¶
type Message struct { ClientID uuid.UUID `json:"clientID"` Signal int `json:"signal"` APPID int `json:"appID"` // also as APP ID Option int `json:"option"` Payload []interface{} `json:"payload"` Target int `json:"target"` Broadcast *Broadcast `json:"broadcast"` NeedBroadcast bool }
func NewMessage ¶
func (*Message) RewriteBroadcast ¶
func (m *Message) RewriteBroadcast()
func (*Message) SetBroadcastPayload ¶ added in v1.7.1
func (m *Message) SetBroadcastPayload(any interface{})
func (*Message) SetBroadcastType ¶ added in v1.7.1
type UserForCooperateFeedback ¶ added in v1.7.1
type UserForCooperateFeedback struct { ID int `json:"id"` Nickname string `json:"nickname"` Avatar string `json:"avatar"` AttachedComponents map[string]string `json:"-"` }
func NewUserForCooperateFeedbackByUser ¶ added in v1.7.1
func NewUserForCooperateFeedbackByUser(user *repository.User) *UserForCooperateFeedback
func (*UserForCooperateFeedback) ExportAttachedComponentDisplayName ¶ added in v1.7.1
func (fuser *UserForCooperateFeedback) ExportAttachedComponentDisplayName() []string
Click to show internal directories.
Click to hide internal directories.