Documentation ¶
Index ¶
- func ActiveStatusKey() twig.Key
- func KillActivityHeartBeat(msgStore store.ExtendedStore, communities []*forest.Community, ...)
- func NewActivityMetadata(status ActiveStatus, ttl time.Duration) (*twig.Data, error)
- func NewActivityNode(statusConversation *forest.Community, builder *forest.Builder, ...) (forest.Node, error)
- func StartActivityHeartBeat(msgStore store.ExtendedStore, communities []*forest.Community, ...)
- type ActiveStatus
- type StatusManager
- type StatusState
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ActiveStatusKey ¶
ActiveStatusKey defines the key used in the activeStatus metadata. Anywhere that references an activeStatus key must call this function
func KillActivityHeartBeat ¶
func NewActivityMetadata ¶
ActivityMetadata creates an acitivity status twig data object for a given status.
example: ```
// Set this node to be a "activity-status" node that lives for five hours ttl = time.Hour * 5 activityMetadata = NewActivityMetadata(Active, ttl) data, _ := activityMetadata.MarshalBinary() statusNode = forest.NewReply(parent, "", data)
```
func NewActivityNode ¶
func StartActivityHeartBeat ¶
func StartActivityHeartBeat(msgStore store.ExtendedStore, communities []*forest.Community, builder *forest.Builder, interval time.Duration)
StartActivityHeartBeat sends an activity message to a number of communities every time a given duration passes. It acts as a heartbeat, letting the communities know a user is currently connected.
Types ¶
type ActiveStatus ¶
type ActiveStatus int
const ( Active ActiveStatus = iota Inactive )
func UnmarshalBinary ¶
func UnmarshalBinary(b []byte) (ActiveStatus, error)
UnmarshalBinary creates an ActiveStatus from a byte slice
func (*ActiveStatus) MarshalBinary ¶
func (s *ActiveStatus) MarshalBinary() []byte
MarshalBinary translates an ActiveStatus into a byte slice
type StatusManager ¶
type StatusManager struct {
// contains filtered or unexported fields
}
StatusManager maps users to their current status. We may eventually want to store more metadata such as `last active`, but for now just knowing is a given user is active is enough
func NewStatusManager ¶
func NewStatusManager() *StatusManager
NewStatusManager instantiates an empty StatusManager struct and returns a pointer to the new object.
func (*StatusManager) HandleNode ¶
func (self *StatusManager) HandleNode(node forest.Node)
HandleNode takes as an argument a reply node. If it is an active status message, it updates the StatusManager accordingly.
func (*StatusManager) IsActive ¶
func (self *StatusManager) IsActive(user fields.QualifiedHash) bool
IsActive returns whether or not a given user is listed as currently active. If the user has never been registered by the StatusManager, they are considered inactive.
func (*StatusManager) Status ¶
func (self *StatusManager) Status(user fields.QualifiedHash) ActiveStatus
Status returns the active status of a given user. If that user has never been registered by the StatusManager, they are considered inactive.
type StatusState ¶
type StatusState struct { Status ActiveStatus Creation time.Time Expiration time.Time }