Documentation
¶
Index ¶
- type BuddyListEvent
- type Event
- type EventQueue
- func (q *EventQueue) Clear()
- func (q *EventQueue) Close()
- func (q *EventQueue) Fetch(ctx context.Context, lastSeqNum uint64, timeout time.Duration) ([]Event, error)
- func (q *EventQueue) GetAllEvents() []Event
- func (q *EventQueue) IsClosed() bool
- func (q *EventQueue) Push(eventType EventType, data interface{})
- func (q *EventQueue) Size() int
- type EventType
- type IMEvent
- type PresenceEvent
- type SentIMEvent
- type TypingEvent
- type UserInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BuddyListEvent ¶
type BuddyListEvent struct {
Action string `json:"action"` // "add", "remove", "update"
Buddy interface{} `json:"buddy"`
Group string `json:"group,omitempty"`
}
BuddyListEvent represents a buddy list change event.
type Event ¶
type Event struct {
Type EventType `json:"type"`
SeqNum uint64 `json:"seqNum"`
Timestamp int64 `json:"timestamp"`
Data interface{} `json:"data"`
}
Event represents an event to be delivered to a web client.
type EventQueue ¶
type EventQueue struct {
// contains filtered or unexported fields
}
EventQueue manages a queue of events for a WebAPI session.
func NewEventQueue ¶
func NewEventQueue(maxSize int) *EventQueue
NewEventQueue creates a new event queue with the specified maximum size.
func (*EventQueue) Close ¶
func (q *EventQueue) Close()
Close closes the event queue, unblocking any waiting fetchers.
func (*EventQueue) Fetch ¶
func (q *EventQueue) Fetch(ctx context.Context, lastSeqNum uint64, timeout time.Duration) ([]Event, error)
Fetch retrieves events from the queue, optionally waiting for new events.
func (*EventQueue) GetAllEvents ¶
func (q *EventQueue) GetAllEvents() []Event
GetAllEvents returns all events in the queue (for debugging).
func (*EventQueue) IsClosed ¶
func (q *EventQueue) IsClosed() bool
IsClosed returns whether the queue is closed.
func (*EventQueue) Push ¶
func (q *EventQueue) Push(eventType EventType, data interface{})
Push adds an event to the queue.
func (*EventQueue) Size ¶
func (q *EventQueue) Size() int
Size returns the current number of events in the queue.
type EventType ¶
type EventType string
EventType defines the type of WebAPI event.
const ( // Event types that can be subscribed to EventTypeBuddyList EventType = "buddylist" EventTypePresence EventType = "presence" EventTypeIM EventType = "im" EventTypeSentIM EventType = "sentIM" EventTypeTyping EventType = "typing" EventTypeStatus EventType = "status" EventTypeOfflineIM EventType = "offlineIM" EventTypeSessionEnded EventType = "sessionEnded" EventTypeRateLimit EventType = "rateLimit" )
type IMEvent ¶
type IMEvent struct {
From string `json:"from"`
Message string `json:"message"`
Timestamp float64 `json:"timestamp"` // float64 for AMF3 encoding
AutoResp bool `json:"autoResponse,omitempty"`
}
IMEvent represents an instant message event.
type PresenceEvent ¶
type PresenceEvent struct {
AimID string `json:"aimId"`
State string `json:"state"` // "online", "offline", "away", "idle"
StatusMsg string `json:"statusMsg,omitempty"`
AwayMsg string `json:"awayMsg,omitempty"`
IdleTime int `json:"idleTime,omitempty"` // Minutes idle
OnlineTime int64 `json:"onlineTime,omitempty"` // Unix timestamp
UserType string `json:"userType"` // "aim", "icq", "admin"
}
PresenceEvent represents a presence change event.
type SentIMEvent ¶
type SentIMEvent struct {
Sender UserInfo `json:"sender"` // Sender user info
Dest UserInfo `json:"dest"` // Destination user info
Message string `json:"message"`
Timestamp float64 `json:"timestamp"` // float64 for AMF3 encoding
AutoResp bool `json:"autoResponse,omitempty"`
}
SentIMEvent represents a sent instant message event.
type TypingEvent ¶
TypingEvent represents a typing notification event.
type UserInfo ¶
type UserInfo struct {
AimID string `json:"aimId"`
DisplayID string `json:"displayId,omitempty"`
UserType string `json:"userType,omitempty"`
State string `json:"state,omitempty"`
OnlineTime float64 `json:"onlineTime,omitempty"` // float64 for AMF3 encoding
}
UserInfo represents basic user information in events.