activeStatus

package
v0.0.0-...-0101299 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 12, 2020 License: Apache-2.0 Imports: 9 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ActiveStatusKey

func ActiveStatusKey() twig.Key

ActiveStatusKey defines the key used in the activeStatus metadata. Anywhere that references an activeStatus key must call this function

func KillActivityHeartBeat

func KillActivityHeartBeat(msgStore store.ExtendedStore, communities []*forest.Community, builder *forest.Builder)

func NewActivityMetadata

func NewActivityMetadata(status ActiveStatus, ttl time.Duration) (*twig.Data, error)

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 NewActivityNode(statusConversation *forest.Community, builder *forest.Builder, status ActiveStatus, ttl time.Duration) (forest.Node, error)

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
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL