Documentation
¶
Index ¶
- type BroadcastMessage
- type Client
- type Handler
- type Hub
- func (h *Hub) BroadcastToTicket(ticketID types.TicketID, message []byte)
- func (h *Hub) Close() error
- func (h *Hub) GetActiveTickets() []types.TicketID
- func (h *Hub) GetClientCount(ticketID types.TicketID) int
- func (h *Hub) GetTotalClientCount() int
- func (h *Hub) NewClient(conn *websocket.Conn, ticketID types.TicketID, userID string) *Client
- func (h *Hub) NewClientWithTabID(conn *websocket.Conn, ticketID types.TicketID, userID string, tabID string) *Client
- func (h *Hub) Register(client *Client)
- func (h *Hub) Run()
- func (h *Hub) SendErrorToTicket(ticketID types.TicketID, content string) error
- func (h *Hub) SendMessageToClient(clientID string, content string, user *websocket_model.User) error
- func (h *Hub) SendMessageToTicket(ticketID types.TicketID, content string, user *websocket_model.User) error
- func (h *Hub) SendStatusToTicket(ticketID types.TicketID, content string) error
- func (h *Hub) SendToClient(clientID string, response *websocket_model.ChatResponse) error
- func (h *Hub) SendToTicket(ticketID types.TicketID, response *websocket_model.ChatResponse) error
- func (h *Hub) SendTraceToClient(clientID string, content string, user *websocket_model.User) error
- func (h *Hub) Unregister(client *Client)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BroadcastMessage ¶
BroadcastMessage represents a message to be broadcast to all clients of a ticket
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is a middleman between the websocket connection and the hub
func (*Client) GetClientID ¶
GetClientID returns the client ID for a client
type Handler ¶
type Handler struct {
// contains filtered or unexported fields
}
Handler handles WebSocket connections for chat functionality
func NewHandler ¶
func NewHandler(hub *Hub, repository interfaces.Repository, useCases *usecase.UseCases) *Handler
NewHandler creates a new WebSocket handler
func NewTestHandler ¶
func NewTestHandler(hub *Hub, repository interfaces.Repository, useCases *usecase.UseCases) (*Handler, *httptest.Server)
NewTestHandler creates a WebSocket handler configured for testing It automatically sets the frontend URL to match the test server
func (*Handler) HandleTicketChat ¶
func (h *Handler) HandleTicketChat(w http.ResponseWriter, r *http.Request)
HandleTicketChat handles WebSocket connections for ticket chat
func (*Handler) WithAllowedOrigins ¶
WithAllowedOrigins sets additional allowed origins (useful for development)
func (*Handler) WithFrontendURL ¶
WithFrontendURL sets the frontend URL for origin checking
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub maintains the set of active clients and broadcasts messages to the clients
func (*Hub) BroadcastToTicket ¶
BroadcastToTicket sends a message to all clients of a specific ticket
func (*Hub) GetActiveTickets ¶
GetActiveTickets returns a list of ticket IDs that have active clients
func (*Hub) GetClientCount ¶
GetClientCount returns the number of clients connected to a specific ticket
func (*Hub) GetTotalClientCount ¶
GetTotalClientCount returns the total number of connected clients across all tickets
func (*Hub) NewClientWithTabID ¶
func (h *Hub) NewClientWithTabID(conn *websocket.Conn, ticketID types.TicketID, userID string, tabID string) *Client
NewClientWithTabID creates a new client with a specific tab ID
func (*Hub) SendErrorToTicket ¶
SendErrorToTicket sends an error message to all clients of a ticket
func (*Hub) SendMessageToClient ¶
func (h *Hub) SendMessageToClient(clientID string, content string, user *websocket_model.User) error
SendMessageToClient sends a chat message to a specific client
func (*Hub) SendMessageToTicket ¶
func (h *Hub) SendMessageToTicket(ticketID types.TicketID, content string, user *websocket_model.User) error
SendMessageToTicket sends a chat message to all clients of a ticket
func (*Hub) SendStatusToTicket ¶
SendStatusToTicket sends a status message to all clients of a ticket
func (*Hub) SendToClient ¶
func (h *Hub) SendToClient(clientID string, response *websocket_model.ChatResponse) error
SendToClient sends a message to a specific client by client ID
func (*Hub) SendToTicket ¶
func (h *Hub) SendToTicket(ticketID types.TicketID, response *websocket_model.ChatResponse) error
SendToTicket is a convenience method to send a WebSocket message to a ticket
func (*Hub) SendTraceToClient ¶
SendTraceToClient sends a trace message to a specific client
func (*Hub) Unregister ¶
Unregister removes a client from the hub