Documentation ¶
Index ¶
- Constants
- Variables
- func GetBinaryMessageType(message []byte) (int, error)
- func GetMessageClientIDForWebsocketServer() uuid.UUID
- type Broadcast
- type Client
- func (c *Client) ExportMappedUserIDToString() string
- func (c *Client) Feedback(message *Message, errorCode int, errorMessage error)
- func (c *Client) FeedbackBinary(message []byte)
- func (c *Client) GetAPPID() int
- func (c *Client) GetID() uuid.UUID
- func (c *Client) IsDead() bool
- func (c *Client) OnBinaryMessage(message []byte)
- func (c *Client) OnTextMessage(message []byte)
- func (c *Client) ReadPump()
- func (c *Client) SetStatus(status int)
- func (c *Client) SetType(clientType int)
- func (c *Client) WritePump()
- type ComponentAttachedUsers
- type Feedback
- type Hub
- func (hub *Hub) BroadcastBinaryToOtherClients(message []byte, currentClient *Client)
- 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) BroadcastToTeamAllClients(message *Message, currentClient *Client, includeCurrentClient bool)
- func (hub *Hub) CleanRoom(roomID int)
- func (hub *Hub) GetClientByID(clientID uuid.UUID) (*Client, error)
- func (hub *Hub) GetInRoomUsersByRoomID(roomID int) *InRoomUsers
- func (hub *Hub) KickClient(client *Client)
- func (hub *Hub) RemoveClient(client *Client)
- func (hub *Hub) SendFeedbackToTargetRoomAllClients(errorCode int, message *Message, teamID int, appID int)
- type InRoomUsers
- func (iru *InRoomUsers) AttachComponent(userID string, componentDisplayNames []string)
- func (iru *InRoomUsers) Count() int
- func (iru *InRoomUsers) DisattachComponent(userID string, componentDisplayNames []string)
- func (iru *InRoomUsers) EnterRoom(user *model.User)
- func (iru *InRoomUsers) FetchAllAttachedUsers() *ComponentAttachedUsers
- func (iru *InRoomUsers) FetchAllInRoomUsers() *InRoomUsersFeedback
- func (iru *InRoomUsers) LeaveRoom(userID string)
- type InRoomUsersFeedback
- type Message
- type MovingMessageBin
- func (*MovingMessageBin) Descriptor() ([]byte, []int)deprecated
- func (x *MovingMessageBin) GetClientID() string
- func (x *MovingMessageBin) GetCursorXInteger() uint32
- func (x *MovingMessageBin) GetCursorXMod() float32
- func (x *MovingMessageBin) GetCursorYInteger() uint32
- func (x *MovingMessageBin) GetCursorYMod() float32
- func (x *MovingMessageBin) GetDisplayNames() string
- func (x *MovingMessageBin) GetNeedBroadcast() bool
- func (x *MovingMessageBin) GetNickname() string
- func (x *MovingMessageBin) GetParentDisplayName() string
- func (x *MovingMessageBin) GetSignal() Signal
- func (x *MovingMessageBin) GetStatus() int32
- func (x *MovingMessageBin) GetTarget() Target
- func (x *MovingMessageBin) GetUserID() string
- func (x *MovingMessageBin) GetWidgetH() uint32
- func (x *MovingMessageBin) GetWidgetW() uint32
- func (x *MovingMessageBin) GetWidgetX() uint32
- func (x *MovingMessageBin) GetWidgetY() uint32
- func (*MovingMessageBin) ProtoMessage()
- func (x *MovingMessageBin) ProtoReflect() protoreflect.Message
- func (x *MovingMessageBin) Reset()
- func (x *MovingMessageBin) String() string
- type Signal
- type Target
- type UserForCooperateFeedback
Constants ¶
const ( CLIENT_TYPE_TEXT = 1 CLIENT_TYPE_BINARY = 2 )
const ( CLIENT_STATUS_ACTIVE = 1 CLIENT_STATUS_DEAD = 2 )
const BINARY_MESSAGE_TYPE_MOVING = 1
const BROADCAST_TYPE_ATTACH_COMPONENT = "attachComponent"
const BROADCAST_TYPE_ENTER = "enter"
const BROADCAST_TYPE_SUFFIX = "/remote"
for broadcast rewrite
const DASHBOARD_APP_ID = -1
const DEFAULT_APP_ID = 0
const DEFAULT_INSTANCE_ID = "SELF_HOST"
const DEFAULT_ROOM_SLOT = 0
const ERROR_AI_AGENT_MAX_TOKEN_OVER_COLLA_BALANCE = 18
const ERROR_CAN_NOT_MOVE_KVSTATE = 10
const ERROR_CAN_NOT_MOVE_SETSTATE = 11
const ERROR_CODE_BROADCAST = 0
const ERROR_CODE_FAILED = 1
const ERROR_CODE_LOGGEDIN = 0
const ERROR_CODE_LOGIN_FAILED = 4
const ERROR_CODE_NEED_ENTER = 2
const ERROR_CODE_OK = 0
for feedback
const ERROR_CODE_PONG = 3
const ERROR_CONTEXT_LENGTH_EXCEEDED = 16
const ERROR_CREATE_OR_UPDATE_STATE_FAILED = 9
const ERROR_CREATE_OR_UPDATE_STATE_OK = 0
const ERROR_CREATE_SNAPSHOT_MIDIFY_HISTORY_FAILED = 12
const ERROR_CREATE_STATE_FAILED = 5
const ERROR_CREATE_STATE_OK = 0
const ERROR_DELETE_STATE_FAILED = 6
const ERROR_DELETE_STATE_OK = 0
const ERROR_FLAG_ONLY_PAID_TEAM_CAN_RUN_SPECIAL_AI_AGENT_MODEL = 19
const ERROR_FORCE_REFRESH_WINDOW = 14
const ERROR_INSUFFICIENT_COLLA = 17
const ERROR_MESSAGE_END = 15
const ERROR_MOVE_STATE_FAILED = 8
const ERROR_MOVE_STATE_OK = 0
const ERROR_PUT_STATE_FAILED = 20
const ERROR_UPDATE_SNAPSHOT_MIDIFY_HISTORY_FAILED = 13
const ERROR_UPDATE_STATE_FAILED = 7
const ERROR_UPDATE_STATE_OK = 0
const HTTP_SERVER_CLIENT_ID = "a97bce38-703b-4f03-b59b-111a00000001"
const OPTION_BROADCAST_ROOM = 1 // 00000000000000000000000000000001; // use as signed int32 in typescript
Variables ¶
var ( Signal_name = map[int32]string{ 0: "SIGNAL_PING", 1: "SIGNAL_ENTER", 2: "SIGNAL_LEAVE", 3: "SIGNAL_CREATE_STATE", 4: "SIGNAL_DELETE_STATE", 5: "SIGNAL_UPDATE_STATE", 6: "SIGNAL_MOVE_STATE", 7: "SIGNAL_CREATE_OR_UPDATE_STATE", 8: "SIGNAL_BROADCAST_ONLY", 9: "SIGNAL_PUT_STATE", 10: "SIGNAL_GLOBAL_BROADCAST_ONLY", 11: "SIGNAL_COOPERATE_ATTACH", 12: "SIGNAL_COOPERATE_DISATTACH", 13: "SIGNAL_MOVE_CURSOR", } Signal_value = map[string]int32{ "SIGNAL_PING": 0, "SIGNAL_ENTER": 1, "SIGNAL_LEAVE": 2, "SIGNAL_CREATE_STATE": 3, "SIGNAL_DELETE_STATE": 4, "SIGNAL_UPDATE_STATE": 5, "SIGNAL_MOVE_STATE": 6, "SIGNAL_CREATE_OR_UPDATE_STATE": 7, "SIGNAL_BROADCAST_ONLY": 8, "SIGNAL_PUT_STATE": 9, "SIGNAL_GLOBAL_BROADCAST_ONLY": 10, "SIGNAL_COOPERATE_ATTACH": 11, "SIGNAL_COOPERATE_DISATTACH": 12, "SIGNAL_MOVE_CURSOR": 13, } )
Enum value maps for Signal.
var ( Target_name = map[int32]string{ 0: "TARGET_NOTHING", 1: "TARGET_COMPONENTS", 2: "TARGET_DEPENDENCIES", 3: "TARGET_DRAG_SHADOW", 4: "TARGET_DOTTED_LINE_SQUARE", 5: "TARGET_DISPLAY_NAME", 6: "TARGET_APPS", 7: "TARGET_RESOURCE", 8: "TARGET_ACTION", 9: "TARGET_CURSOR", } Target_value = map[string]int32{ "TARGET_NOTHING": 0, "TARGET_COMPONENTS": 1, "TARGET_DEPENDENCIES": 2, "TARGET_DRAG_SHADOW": 3, "TARGET_DOTTED_LINE_SQUARE": 4, "TARGET_DISPLAY_NAME": 5, "TARGET_APPS": 6, "TARGET_RESOURCE": 7, "TARGET_ACTION": 8, "TARGET_CURSOR": 9, } )
Enum value maps for Target.
var File_cursor_sync_proto protoreflect.FileDescriptor
Functions ¶
func GetBinaryMessageType ¶
Types ¶
type Broadcast ¶
type Broadcast struct { Type string `json:"type"` Payload interface{} `json:"payload"` }
type Client ¶
type Client struct { ID uuid.UUID Status int Type int MappedUserID int MappedUserUID uuid.UUID IsLoggedIn bool Hub *Hub // The websocket connection. Conn *websocket.Conn // Buffered channel of outbound messages. Send chan []byte // teamID, 0 by default in SELF_HOST mode TeamID int // TeamID // appID, 0 by default, -1 for dashboard APPID int }
Client is a middleman between the websocket connection and the hub.
func (*Client) ExportMappedUserIDToString ¶
func (*Client) FeedbackBinary ¶
func (*Client) OnBinaryMessage ¶
func (*Client) OnTextMessage ¶
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.
All message types (TextMessage, BinaryMessage, CloseMessage, PingMessage and PongMessage) are supported.
type ComponentAttachedUsers ¶
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 BinaryClients map[uuid.UUID]*Client // inbound messages from the clients. // try “`hub.Broadcast <- []byte(message)“` Broadcast chan []byte // on message process OnTextMessage chan *Message OnBinaryMessage chan []byte // register requests from the clients. Register chan *Client RegisterBinary chan *Client // unregister requests from the clients. Unregister chan *Client // InRoomUsers InRoomUsersMap map[int]*InRoomUsers // map[roomID]*InRoomUsers // sotrage Storage *storage.Storage // attribute group AttributeGroup *accesscontrol.AttributeGroup }
clients hub, maintains active clients and broadcast messags.
func NewHub ¶
func NewHub(s *storage.Storage, attrg *accesscontrol.AttributeGroup) *Hub
func (*Hub) BroadcastBinaryToOtherClients ¶
func (*Hub) BroadcastToGlobal ¶
func (hub *Hub) BroadcastToGlobal(message *Message, currentClient *Client, includeCurrentClient bool)
WARRING: This method will broadcast to server all clients. Use it carefully.
func (*Hub) BroadcastToOtherClients ¶
func (*Hub) BroadcastToRoomAllClients ¶
func (*Hub) BroadcastToTeamAllClients ¶
func (*Hub) GetInRoomUsersByRoomID ¶
func (hub *Hub) GetInRoomUsersByRoomID(roomID int) *InRoomUsers
func (*Hub) KickClient ¶
func (*Hub) RemoveClient ¶
type InRoomUsers ¶
type InRoomUsers struct { RoomID int All []*UserForCooperateFeedback // []*UserForCooperateFeedback AllUsers map[string]*UserForCooperateFeedback // map[user.ID]*UserForCooperateFeedback AttachedUserList map[string][]*UserForCooperateFeedback // map[component.DisplayName][]*UserForCooperateFeedback }
func NewInRoomUsers ¶
func NewInRoomUsers(roomID int) *InRoomUsers
func (*InRoomUsers) AttachComponent ¶
func (iru *InRoomUsers) AttachComponent(userID string, componentDisplayNames []string)
func (*InRoomUsers) Count ¶
func (iru *InRoomUsers) Count() int
func (*InRoomUsers) DisattachComponent ¶
func (iru *InRoomUsers) DisattachComponent(userID string, componentDisplayNames []string)
func (*InRoomUsers) EnterRoom ¶
func (iru *InRoomUsers) EnterRoom(user *model.User)
func (*InRoomUsers) FetchAllAttachedUsers ¶
func (iru *InRoomUsers) FetchAllAttachedUsers() *ComponentAttachedUsers
func (*InRoomUsers) FetchAllInRoomUsers ¶
func (iru *InRoomUsers) FetchAllInRoomUsers() *InRoomUsersFeedback
func (*InRoomUsers) LeaveRoom ¶
func (iru *InRoomUsers) LeaveRoom(userID string)
type InRoomUsersFeedback ¶
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 NewEmptyMessage ¶
func NewMessage ¶
func (*Message) RewriteBroadcast ¶
func (m *Message) RewriteBroadcast()
func (*Message) SetBroadcastPayload ¶
func (m *Message) SetBroadcastPayload(any interface{})
func (*Message) SetBroadcastType ¶
type MovingMessageBin ¶
type MovingMessageBin struct { Signal Signal `protobuf:"varint,1,opt,name=signal,proto3,enum=tutorial.Signal" json:"signal,omitempty"` // see package websocket const define Target Target `protobuf:"varint,2,opt,name=target,proto3,enum=tutorial.Target" json:"target,omitempty"` // ClientID string `protobuf:"bytes,3,opt,name=clientID,proto3" json:"clientID,omitempty"` // message sender client ID NeedBroadcast bool `protobuf:"varint,4,opt,name=needBroadcast,proto3" json:"needBroadcast,omitempty"` UserID string `protobuf:"bytes,5,opt,name=userID,proto3" json:"userID,omitempty"` // message sender user ID Nickname string `protobuf:"bytes,6,opt,name=nickname,proto3" json:"nickname,omitempty"` // message sender user ID Status int32 `protobuf:"varint,7,opt,name=status,proto3" json:"status,omitempty"` // set instance to status, 0 for empty status ParentDisplayName string `protobuf:"bytes,8,opt,name=parentDisplayName,proto3" json:"parentDisplayName,omitempty"` // parent component displayname DisplayNames string `protobuf:"bytes,9,opt,name=displayNames,proto3" json:"displayNames,omitempty"` // message affected component display names, separate with comma "," CursorXInteger uint32 `protobuf:"varint,10,opt,name=cursorXInteger,proto3" json:"cursorXInteger,omitempty"` // cursor's position with dot number CursorYInteger uint32 `protobuf:"varint,11,opt,name=cursorYInteger,proto3" json:"cursorYInteger,omitempty"` // cursor's position with dot number CursorXMod float32 `protobuf:"fixed32,12,opt,name=cursorXMod,proto3" json:"cursorXMod,omitempty"` // cursor's position with dot number CursorYMod float32 `protobuf:"fixed32,13,opt,name=cursorYMod,proto3" json:"cursorYMod,omitempty"` // cursor's position with dot number WidgetX uint32 `protobuf:"varint,14,opt,name=widgetX,proto3" json:"widgetX,omitempty"` // widget'position with dot number WidgetY uint32 `protobuf:"varint,15,opt,name=widgetY,proto3" json:"widgetY,omitempty"` // widget'position with dot number WidgetW uint32 `protobuf:"varint,16,opt,name=widgetW,proto3" json:"widgetW,omitempty"` // widget'shape with dot number WidgetH uint32 `protobuf:"varint,17,opt,name=widgetH,proto3" json:"widgetH,omitempty"` // widget'shape with dot number // contains filtered or unexported fields }
func (*MovingMessageBin) Descriptor
deprecated
func (*MovingMessageBin) Descriptor() ([]byte, []int)
Deprecated: Use MovingMessageBin.ProtoReflect.Descriptor instead.
func (*MovingMessageBin) GetClientID ¶
func (x *MovingMessageBin) GetClientID() string
func (*MovingMessageBin) GetCursorXInteger ¶
func (x *MovingMessageBin) GetCursorXInteger() uint32
func (*MovingMessageBin) GetCursorXMod ¶
func (x *MovingMessageBin) GetCursorXMod() float32
func (*MovingMessageBin) GetCursorYInteger ¶
func (x *MovingMessageBin) GetCursorYInteger() uint32
func (*MovingMessageBin) GetCursorYMod ¶
func (x *MovingMessageBin) GetCursorYMod() float32
func (*MovingMessageBin) GetDisplayNames ¶
func (x *MovingMessageBin) GetDisplayNames() string
func (*MovingMessageBin) GetNeedBroadcast ¶
func (x *MovingMessageBin) GetNeedBroadcast() bool
func (*MovingMessageBin) GetNickname ¶
func (x *MovingMessageBin) GetNickname() string
func (*MovingMessageBin) GetParentDisplayName ¶
func (x *MovingMessageBin) GetParentDisplayName() string
func (*MovingMessageBin) GetSignal ¶
func (x *MovingMessageBin) GetSignal() Signal
func (*MovingMessageBin) GetStatus ¶
func (x *MovingMessageBin) GetStatus() int32
func (*MovingMessageBin) GetTarget ¶
func (x *MovingMessageBin) GetTarget() Target
func (*MovingMessageBin) GetUserID ¶
func (x *MovingMessageBin) GetUserID() string
func (*MovingMessageBin) GetWidgetH ¶
func (x *MovingMessageBin) GetWidgetH() uint32
func (*MovingMessageBin) GetWidgetW ¶
func (x *MovingMessageBin) GetWidgetW() uint32
func (*MovingMessageBin) GetWidgetX ¶
func (x *MovingMessageBin) GetWidgetX() uint32
func (*MovingMessageBin) GetWidgetY ¶
func (x *MovingMessageBin) GetWidgetY() uint32
func (*MovingMessageBin) ProtoMessage ¶
func (*MovingMessageBin) ProtoMessage()
func (*MovingMessageBin) ProtoReflect ¶
func (x *MovingMessageBin) ProtoReflect() protoreflect.Message
func (*MovingMessageBin) Reset ¶
func (x *MovingMessageBin) Reset()
func (*MovingMessageBin) String ¶
func (x *MovingMessageBin) String() string
type Signal ¶
type Signal int32
const ( Signal_SIGNAL_PING Signal = 0 Signal_SIGNAL_ENTER Signal = 1 Signal_SIGNAL_LEAVE Signal = 2 Signal_SIGNAL_CREATE_STATE Signal = 3 Signal_SIGNAL_DELETE_STATE Signal = 4 Signal_SIGNAL_UPDATE_STATE Signal = 5 Signal_SIGNAL_MOVE_STATE Signal = 6 Signal_SIGNAL_CREATE_OR_UPDATE_STATE Signal = 7 Signal_SIGNAL_BROADCAST_ONLY Signal = 8 Signal_SIGNAL_PUT_STATE Signal = 9 Signal_SIGNAL_GLOBAL_BROADCAST_ONLY Signal = 10 Signal_SIGNAL_COOPERATE_ATTACH Signal = 11 Signal_SIGNAL_COOPERATE_DISATTACH Signal = 12 Signal_SIGNAL_MOVE_CURSOR Signal = 13 )
func (Signal) Descriptor ¶
func (Signal) Descriptor() protoreflect.EnumDescriptor
func (Signal) EnumDescriptor
deprecated
func (Signal) Number ¶
func (x Signal) Number() protoreflect.EnumNumber
func (Signal) Type ¶
func (Signal) Type() protoreflect.EnumType
type Target ¶
type Target int32
const ( Target_TARGET_NOTHING Target = 0 // placeholder for nothing Target_TARGET_COMPONENTS Target = 1 // ComponentsState Target_TARGET_DEPENDENCIES Target = 2 // DependenciesState Target_TARGET_DRAG_SHADOW Target = 3 // DragShadowState Target_TARGET_DOTTED_LINE_SQUARE Target = 4 // DottedLineSquareState Target_TARGET_DISPLAY_NAME Target = 5 // DisplayNameState Target_TARGET_APPS Target = 6 // only for broadcast Target_TARGET_RESOURCE Target = 7 // only for broadcast Target_TARGET_ACTION Target = 8 // only for broadcast Target_TARGET_CURSOR Target = 9 // only for broadcast )
func (Target) Descriptor ¶
func (Target) Descriptor() protoreflect.EnumDescriptor
func (Target) EnumDescriptor
deprecated
func (Target) Number ¶
func (x Target) Number() protoreflect.EnumNumber
func (Target) Type ¶
func (Target) Type() protoreflect.EnumType
type UserForCooperateFeedback ¶
type UserForCooperateFeedback struct { ID string `json:"id"` Nickname string `json:"nickname"` Avatar string `json:"avatar"` AttachedComponents map[string]string `json:"-"` }
func NewUserForCooperateFeedbackByUser ¶
func NewUserForCooperateFeedbackByUser(user *model.User) *UserForCooperateFeedback
func (*UserForCooperateFeedback) ExportAttachedComponentDisplayName ¶
func (fuser *UserForCooperateFeedback) ExportAttachedComponentDisplayName() []string