Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ClientInterface ¶
type ClientInterface interface { // GetUsername returns the client's username. GetUsername() string // SendMessage sends a message to the client over the websocket. SendMessage(messages.BaseMessage) // CloseSendChannel closes the client's outgoing message channel. CloseSendChannel() // GetID returns the stable user ID (e.g., from Keycloak). GetID() string // GetClientID returns the OAuth client ID used to identify the source application, // such as "ChatClient" or "WebClient". GetClientID() string // StartConnectionTimer records the time the client connected. StartConnectionTimer() // GetConnectedAt returns the timestamp when the client connected. GetConnectedAt() time.Time }
ClientInterface defines the contract for a client that connects to the hub over a websocket and can send and receive messages.
type HubInterface ¶
type HubInterface interface { // Broadcast sends a message to all connected clients. Broadcast(messages.BaseMessage) // Whisper sends a private message to a specific client. Whisper(messages.BaseMessage) // RegisterClient adds a client to the hub, associating it with a unique client ID. RegisterClient(ClientInterface, string) // UnregisterClient removes a client from the hub using the provided client ID. UnregisterClient(ClientInterface, string) // SendMessage sends a message into the hub’s internal message loop for processing. SendMessage(messages.BaseMessage) // GetConnectedUsers returns a list of users currently connected to the hub. GetConnectedUsers() []chat.UserStatusPayload // GetCachedChatMessages returns a list of recent chat messages from the cache. GetCachedChatMessages() []models.ChatMessage // FindUsernameByUserID returns the username associated with the given user ID, if any. FindUsernameByUserID(userID string) (string, bool) }
HubInterface defines the contract for a Hub that manages connected clients, message broadcasting, private messaging, and cached message retrieval.
Click to show internal directories.
Click to hide internal directories.