Documentation
¶
Index ¶
- func MarshalEnvelope(msgType string, data any, ref string) ([]byte, error)
- func ParseData[T any](env Envelope) (T, error)
- type Channel
- type ChannelCreateRequest
- type ChannelInviteRequest
- type ChannelJoinMsg
- type ChannelJoinRequest
- type ChannelListMsg
- type ChannelListResponse
- type ChannelUnreadCount
- type Client
- func (c *Client) Close()
- func (c *Client) Connect() (*Hello, error)
- func (c *Client) CreateChannel(name string, public bool, members []string)
- func (c *Client) DMOpen(username string)
- func (c *Client) Identify(username string) error
- func (c *Client) InviteUser(channel, username string)
- func (c *Client) JoinChannel(channel string)
- func (c *Client) MarkRead(channel string, messageID *int)
- func (c *Client) ReadPump(p *tea.Program)
- func (c *Client) Reconnect() tea.Cmd
- func (c *Client) RequestChannels()
- func (c *Client) RequestDMList()
- func (c *Client) RequestHistory(channel string, before, limit int)
- func (c *Client) RequestUnread(channel string)
- func (c *Client) RequestUnreadCounts()
- func (c *Client) RequestUsers()
- func (c *Client) SendMessage(channel, body string)
- func (c *Client) WritePump()
- type ConnectedMsg
- type DM
- type DMListMsg
- type DMListResponse
- type DMOpenMsg
- type DMOpenRequest
- type DMOpenResponse
- type DisconnectedMsg
- type Envelope
- type Hello
- type HistoryMsg
- type HistoryRequest
- type HistoryResponse
- type IdentifyRequest
- type MarkReadRequest
- type Message
- type MessageNewEvent
- type MessageNewMsg
- type MessageSentMsg
- type PresenceEvent
- type PresenceMsg
- type ReconnectingMsg
- type RegisterRequest
- type SendMessageRequest
- type UnreadCountsMsg
- type UnreadCountsResponse
- type UnreadMsg
- type UnreadRequest
- type UnreadResponse
- type User
- type UserListMsg
- type UserListResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MarshalEnvelope ¶
MarshalEnvelope creates an Envelope with the given type and data payload.
Types ¶
type Channel ¶
type Channel struct {
Name string `json:"name"`
Public bool `json:"public"`
Member bool `json:"member"`
}
Channel represents a chat channel from the server.
type ChannelCreateRequest ¶
type ChannelCreateRequest struct {
Name string `json:"name"`
Public bool `json:"public"`
Members []string `json:"members,omitempty"`
}
ChannelCreateRequest creates a new channel.
type ChannelInviteRequest ¶
type ChannelInviteRequest struct {
Channel string `json:"channel"`
Username string `json:"username"`
}
ChannelInviteRequest invites a user to a channel.
type ChannelJoinMsg ¶
type ChannelJoinMsg struct{}
type ChannelJoinRequest ¶
type ChannelJoinRequest struct {
Channel string `json:"channel"`
}
ChannelJoinRequest joins a public channel.
type ChannelListMsg ¶
type ChannelListMsg struct {
Channels []Channel
}
type ChannelListResponse ¶
type ChannelListResponse struct {
Channels []Channel `json:"channels"`
}
ChannelListResponse is the payload of a channel_list response.
type ChannelUnreadCount ¶
type ChannelUnreadCount struct {
Channel string `json:"channel"`
ChannelType string `json:"type"`
UnreadCount int `json:"unread_count"`
MentionCount int `json:"mention_count"`
}
ChannelUnreadCount holds per-channel unread and mention counts.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages a WebSocket connection to a sharkfin daemon.
func (*Client) CreateChannel ¶
CreateChannel creates a new channel.
func (*Client) Identify ¶
Identify authenticates as an existing user, falling back to register. Writes directly to the connection (WritePump is not yet running during handshake).
func (*Client) InviteUser ¶
InviteUser invites a user to a channel.
func (*Client) JoinChannel ¶
JoinChannel joins a public channel.
func (*Client) ReadPump ¶
ReadPump reads messages from the WebSocket and dispatches them as tea.Msg via p.Send().
func (*Client) Reconnect ¶
Reconnect returns a tea.Cmd that attempts to reconnect with exponential backoff. It blocks until a connection is re-established, sending ReconnectingMsg on each attempt.
func (*Client) RequestChannels ¶
func (c *Client) RequestChannels()
RequestChannels requests the channel list.
func (*Client) RequestDMList ¶
func (c *Client) RequestDMList()
RequestDMList requests the DM conversation list.
func (*Client) RequestHistory ¶
RequestHistory requests paginated message history.
func (*Client) RequestUnread ¶
RequestUnread requests unread messages for a channel (advances read cursor).
func (*Client) RequestUnreadCounts ¶
func (c *Client) RequestUnreadCounts()
RequestUnreadCounts requests per-channel unread and mention counts.
func (*Client) SendMessage ¶
SendMessage sends a chat message to a channel.
type ConnectedMsg ¶
type ConnectedMsg struct{}
type DM ¶
type DM struct {
Channel string `json:"channel"`
Participant string `json:"participant,omitempty"` // MCP (user-scoped)
Participants []string `json:"participants,omitempty"` // WS (admin-scoped)
Member bool `json:"member"`
}
DM represents a direct message conversation.
type DMListResponse ¶
type DMListResponse struct {
DMs []DM `json:"dms"`
}
DMListResponse is the payload of a dm_list response.
type DMOpenRequest ¶
type DMOpenRequest struct {
Username string `json:"username"`
}
DMOpenRequest opens or creates a DM with a user.
type DMOpenResponse ¶
type DMOpenResponse struct {
Channel string `json:"channel"`
Participant string `json:"participant"`
Created bool `json:"created"`
}
DMOpenResponse is the payload of a dm_open response.
type DisconnectedMsg ¶
type DisconnectedMsg struct {
Err error
}
type Envelope ¶
type Envelope struct {
Type string `json:"type"`
D json.RawMessage `json:"d,omitempty"`
Ref string `json:"ref,omitempty"`
OK *bool `json:"ok,omitempty"`
}
Envelope is the top-level JSON structure for all sharkfin WS messages.
func ParseEnvelope ¶
ParseEnvelope parses a raw JSON message into an Envelope.
type Hello ¶
type Hello struct {
HeartbeatInterval int `json:"heartbeat_interval"`
}
Hello is sent by the server on connection.
type HistoryMsg ¶
type HistoryRequest ¶
type HistoryRequest struct {
Channel string `json:"channel"`
Before int `json:"before,omitempty"`
Limit int `json:"limit,omitempty"`
}
HistoryRequest requests message history for a channel.
type HistoryResponse ¶
type HistoryResponse struct {
Channel string `json:"channel"`
Messages []Message `json:"messages"`
}
HistoryResponse is the payload of a history response.
type IdentifyRequest ¶
IdentifyRequest is sent to authenticate as an existing user.
type MarkReadRequest ¶
type MarkReadRequest struct {
Channel string `json:"channel"`
MessageID *int `json:"message_id,omitempty"`
}
MarkReadRequest advances the read cursor for a channel.
type Message ¶
type Message struct {
ID int `json:"id"`
Channel string `json:"channel"`
From string `json:"from"`
Body string `json:"body"`
SentAt time.Time `json:"sent_at"`
ThreadID *int `json:"thread_id,omitempty"`
}
Message represents a chat message from the server.
func (*Message) UnmarshalJSON ¶
type MessageNewEvent ¶
type MessageNewEvent struct {
ID int `json:"id"`
Channel string `json:"channel"`
ChannelType string `json:"channel_type"`
From string `json:"from"`
Body string `json:"body"`
SentAt time.Time `json:"sent_at"`
ThreadID *int `json:"thread_id,omitempty"`
Mentions []string `json:"mentions,omitempty"`
}
MessageNewEvent is a server push for new messages.
func (*MessageNewEvent) UnmarshalJSON ¶
func (e *MessageNewEvent) UnmarshalJSON(data []byte) error
type MessageNewMsg ¶
type MessageNewMsg = MessageNewEvent
type MessageSentMsg ¶
type MessageSentMsg struct{}
type PresenceEvent ¶
PresenceEvent is a server push for user presence changes.
type PresenceMsg ¶
type PresenceMsg = PresenceEvent
type ReconnectingMsg ¶
type ReconnectingMsg struct {
Attempt int
}
type RegisterRequest ¶
RegisterRequest is sent to create a new user.
type SendMessageRequest ¶
type SendMessageRequest struct {
Channel string `json:"channel"`
Body string `json:"body"`
ThreadID *int `json:"thread_id,omitempty"`
}
SendMessageRequest sends a message to a channel.
type UnreadCountsMsg ¶
type UnreadCountsMsg struct {
Counts []ChannelUnreadCount
}
type UnreadCountsResponse ¶
type UnreadCountsResponse struct {
Counts []ChannelUnreadCount `json:"counts"`
}
UnreadCountsResponse is the payload of an unread_counts response.
type UnreadRequest ¶
type UnreadRequest struct {
Channel string `json:"channel,omitempty"`
MentionsOnly bool `json:"mentions_only,omitempty"`
ThreadID *int `json:"thread_id,omitempty"`
}
UnreadRequest requests unread messages.
type UnreadResponse ¶
type UnreadResponse struct {
Channel string `json:"channel,omitempty"`
Messages []Message `json:"messages"`
}
UnreadResponse is the payload of an unread_messages response.
type UserListMsg ¶
type UserListMsg struct {
Users []User
}
type UserListResponse ¶
type UserListResponse struct {
Users []User `json:"users"`
}
UserListResponse is the payload of a user_list response.