innerpresence

package
v0.4.18 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package innerpresence provides the implementation of Presence. If the client is watching a document, the presence is shared with all other clients watching the same document.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map struct {
	// contains filtered or unexported fields
}

Map is a map of Presence. It is wrapper of sync.Map to use type-safe.

func NewMap

func NewMap() *Map

NewMap creates a new instance of Map.

func (*Map) DeepCopy

func (m *Map) DeepCopy() *Map

DeepCopy copies itself deeply.

func (*Map) Delete

func (m *Map) Delete(clientID string)

Delete deletes the presence for the given clientID.

func (*Map) Has

func (m *Map) Has(clientID string) bool

Has returns whether the given clientID exists.

func (*Map) Load

func (m *Map) Load(clientID string) Presence

Load returns the presence for the given clientID.

func (*Map) LoadOrStore

func (m *Map) LoadOrStore(clientID string, presence Presence) Presence

LoadOrStore returns the existing presence if exists. Otherwise, it stores and returns the given presence.

func (*Map) Range

func (m *Map) Range(f func(clientID string, presence Presence) bool)

Range calls f sequentially for each key and value present in the map.

func (*Map) Store

func (m *Map) Store(clientID string, presence Presence)

Store stores the given presence to the map.

type Presence

type Presence map[string]string

Presence represents custom presence that can be defined by the client.

func NewPresence

func NewPresence() Presence

NewPresence creates a new instance of Presence.

func (Presence) Clear

func (p Presence) Clear()

Clear clears the presence.

func (Presence) DeepCopy

func (p Presence) DeepCopy() Presence

DeepCopy copies itself deeply.

func (Presence) Set

func (p Presence) Set(key string, value string)

Set sets the value of the given key.

type PresenceChange

type PresenceChange struct {
	ChangeType PresenceChangeType `json:"changeType"`
	Presence   Presence           `json:"presence"`
}

PresenceChange represents the change of presence.

func NewChangeFromJSON

func NewChangeFromJSON(encodedChange string) (*PresenceChange, error)

NewChangeFromJSON creates a new instance of PresenceChange from JSON.

type PresenceChangeType

type PresenceChangeType string

PresenceChangeType represents the type of presence change.

const (
	// Put represents the presence is put.
	Put PresenceChangeType = "put"

	// Clear represents the presence is cleared.
	Clear PresenceChangeType = "clear"
)

Jump to

Keyboard shortcuts

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