Documentation
      ¶
    
    
  
    
  
    Overview ¶
Package websocket starts a WebSocket service forwarding internal events to http clients
Index ¶
- Constants
 - func ClearSession(session *melody.Session)
 - func Marshal(m Message) []byte
 - func NewErrorMessage(e error) []byte
 - func NewErrorMessageString(e string) []byte
 - func UpdateSessionFromClaims(session *melody.Session, claims claim.Claims, pool *views.ClientsPool)
 - type ChatHandler
 - func (c *ChatHandler) AppendUserToRoom(room *chat.ChatRoom, userName string)
 - func (c *ChatHandler) BroadcastChatMessage(ctx context.Context, msg *chat.ChatEvent) error
 - func (c *ChatHandler) FindOrCreateRoom(ctx context.Context, room *chat.ChatRoom, createIfNotExists bool) (*chat.ChatRoom, error)
 - func (c *ChatHandler) InitHandlers(serviceCtx context.Context)
 - func (c *ChatHandler) RemoveUserFromRoom(room *chat.ChatRoom, userName string)
 
- type ChatMessage
 - type ChatMessageType
 - type Message
 - type MessageType
 - type WebsocketHandler
 - func (w *WebsocketHandler) BroadcastActivityEvent(ctx context.Context, event *activity.PostActivityEvent) error
 - func (w *WebsocketHandler) BroadcastIDMChangeEvent(ctx context.Context, event *idm.ChangeEvent) error
 - func (w *WebsocketHandler) BroadcastNodeChangeEvent(ctx context.Context, event *tree.NodeChangeEvent) error
 - func (w *WebsocketHandler) BroadcastTaskChangeEvent(ctx context.Context, event *jobs.TaskChangeEvent) error
 - func (w *WebsocketHandler) InitHandlers(serviceCtx context.Context)
 
Constants ¶
      View Source
      
  
    const SessionProfileKey = "profile"
    
      View Source
      
  
    const SessionRolesKey = "roles"
    
      View Source
      
  
    const (
	SessionRoomKey = "room"
)
    
      View Source
      
  
    const SessionUsernameKey = "user"
    
      View Source
      
  
const SessionWorkspacesKey = "workspaces"
    Variables ¶
This section is empty.
Functions ¶
func ClearSession ¶
func ClearSession(session *melody.Session)
func UpdateSessionFromClaims ¶
func UpdateSessionFromClaims(session *melody.Session, claims claim.Claims, pool *views.ClientsPool)
Types ¶
type ChatHandler ¶
type ChatHandler struct {
	Websocket *melody.Melody
	Pool      *views.ClientsPool
}
    func NewChatHandler ¶
func NewChatHandler(serviceCtx context.Context) *ChatHandler
func (*ChatHandler) AppendUserToRoom ¶
func (c *ChatHandler) AppendUserToRoom(room *chat.ChatRoom, userName string)
func (*ChatHandler) BroadcastChatMessage ¶
func (*ChatHandler) FindOrCreateRoom ¶
func (*ChatHandler) InitHandlers ¶
func (c *ChatHandler) InitHandlers(serviceCtx context.Context)
func (*ChatHandler) RemoveUserFromRoom ¶
func (c *ChatHandler) RemoveUserFromRoom(room *chat.ChatRoom, userName string)
type ChatMessage ¶
type ChatMessage struct {
	Type     ChatMessageType `json:"@type"`
	RoomType chat.RoomType
	Payload  string
}
    type ChatMessageType ¶
type ChatMessageType string
const ( JoinRoom ChatMessageType = "join" LeaveRoom ChatMessageType = "leave" PostMessage ChatMessageType = "msg" )
type Message ¶
type Message struct {
	Type  MessageType `json:"@type"`
	JWT   string      `json:"jwt"`
	Error string      `json:"error"`
}
    Should pass JWT instead of username
type MessageType ¶
type MessageType string
const ( MsgSubscribe MessageType = "subscribe" MsgUnsubscribe MessageType = "unsubscribe" MsgError MessageType = "error" )
type WebsocketHandler ¶
type WebsocketHandler struct {
	Websocket   *melody.Melody
	EventRouter *views.RouterEventFilter
}
    func NewWebSocketHandler ¶
func NewWebSocketHandler(serviceCtx context.Context) *WebsocketHandler
func (*WebsocketHandler) BroadcastActivityEvent ¶
func (w *WebsocketHandler) BroadcastActivityEvent(ctx context.Context, event *activity.PostActivityEvent) error
func (*WebsocketHandler) BroadcastIDMChangeEvent ¶
func (w *WebsocketHandler) BroadcastIDMChangeEvent(ctx context.Context, event *idm.ChangeEvent) error
func (*WebsocketHandler) BroadcastNodeChangeEvent ¶
func (w *WebsocketHandler) BroadcastNodeChangeEvent(ctx context.Context, event *tree.NodeChangeEvent) error
func (*WebsocketHandler) BroadcastTaskChangeEvent ¶
func (w *WebsocketHandler) BroadcastTaskChangeEvent(ctx context.Context, event *jobs.TaskChangeEvent) error
func (*WebsocketHandler) InitHandlers ¶
func (w *WebsocketHandler) InitHandlers(serviceCtx context.Context)
      
      Source Files
      ¶
    
- chat-handler.go
 - messages.go
 - sessions.go
 - ws-handler.go
 
 Click to show internal directories. 
   Click to hide internal directories.