universe

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2022 License: AGPL-3.0 Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const MegaEmojiRadius = 100.0
View Source
const MegaEmojiTimeWindow = 10 * time.Second // time window for megaEmoji
View Source
const MegaEmojiTriggerCount = 10

Variables

This section is empty.

Functions

func TimeInformer

func TimeInformer(client safemqtt.Client)

Types

type ConnectedUsers

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

func NewUsers

func NewUsers(world *WorldController) *ConnectedUsers

func (*ConnectedUsers) Add

func (cu *ConnectedUsers) Add(u *User)

func (*ConnectedUsers) Broadcast

func (cu *ConnectedUsers) Broadcast(message *websocket.PreparedMessage)

func (*ConnectedUsers) BroadcastDisconnectedUsers

func (cu *ConnectedUsers) BroadcastDisconnectedUsers()

func (*ConnectedUsers) BroadcastPositions

func (cu *ConnectedUsers) BroadcastPositions()

func (*ConnectedUsers) BroadcastUsersUpdate

func (cu *ConnectedUsers) BroadcastUsersUpdate()

func (*ConnectedUsers) Delete

func (cu *ConnectedUsers) Delete(id uuid.UUID)

func (*ConnectedUsers) Get

func (cu *ConnectedUsers) Get(id uuid.UUID) (*User, bool)

func (*ConnectedUsers) GetOnSpace

func (cu *ConnectedUsers) GetOnSpace(spaceId uuid.UUID) []*User

func (*ConnectedUsers) Num

func (cu *ConnectedUsers) Num() int

func (*ConnectedUsers) PerformBroadcast

func (cu *ConnectedUsers) PerformBroadcast(message *websocket.PreparedMessage)

func (*ConnectedUsers) Run

func (cu *ConnectedUsers) Run()

TODO: this method never ends

func (*ConnectedUsers) UserLeft

func (cu *ConnectedUsers) UserLeft(userId uuid.UUID)

type ControllerHub

type ControllerHub struct {
	Worlds *utils.SyncMap[uuid.UUID, *WorldController]

	DB           *storage.Database
	SpaceStorage space.Storage
	WorldStorage world.Storage
	UserStorage  user.Storage
	// contains filtered or unexported fields
}

func NewControllerHub

func NewControllerHub(
	cfg *config.Config, networking *net.Networking, msgBuilder *message.Builder, db *storage.Database,
	mqttClient safemqtt.Client,
) (*ControllerHub, error)

func (*ControllerHub) AddWorldController

func (ch *ControllerHub) AddWorldController(worldID uuid.UUID) (*WorldController, error)

func (*ControllerHub) CancelCleanupSpace added in v0.2.0

func (ch *ControllerHub) CancelCleanupSpace(id uuid.UUID)

func (*ControllerHub) CancelCleanupUser added in v0.2.0

func (ch *ControllerHub) CancelCleanupUser(id uuid.UUID)

func (*ControllerHub) ChangeHandler

func (ch *ControllerHub) ChangeHandler(client mqtt.Client, message mqtt.Message) error

func (*ControllerHub) CleanupOnlineUsers added in v0.2.0

func (ch *ControllerHub) CleanupOnlineUsers() error

func (*ControllerHub) CleanupSpace added in v0.2.0

func (ch *ControllerHub) CleanupSpace(id uuid.UUID) error

func (*ControllerHub) CleanupSpaceWithDelay added in v0.2.0

func (ch *ControllerHub) CleanupSpaceWithDelay(id uuid.UUID, fn utils.TimerFunc[uuid.UUID])

func (*ControllerHub) CleanupSpacesWithDelay added in v0.2.0

func (ch *ControllerHub) CleanupSpacesWithDelay() error

func (*ControllerHub) CleanupUser added in v0.2.0

func (ch *ControllerHub) CleanupUser(id uuid.UUID) error

func (*ControllerHub) CleanupUserWithDelay added in v0.2.0

func (ch *ControllerHub) CleanupUserWithDelay(id uuid.UUID, fn utils.TimerFunc[uuid.UUID])

func (*ControllerHub) CleanupUsersWithDelay added in v0.2.0

func (ch *ControllerHub) CleanupUsersWithDelay() error

func (*ControllerHub) GetNodeSettings

func (ch *ControllerHub) GetNodeSettings() error

func (*ControllerHub) GetUserSpawnPoint

func (ch *ControllerHub) GetUserSpawnPoint(uid uuid.UUID, URL *url.URL) (uuid.UUID, cmath.Vec3, error)

func (*ControllerHub) GetWorldController

func (ch *ControllerHub) GetWorldController(worldID uuid.UUID) (*WorldController, error)

func (*ControllerHub) HashUserID added in v0.3.0

func (ch *ControllerHub) HashUserID(userId uuid.UUID) string

func (*ControllerHub) NetworkRunner

func (ch *ControllerHub) NetworkRunner()

TODO: this method never ends

func (*ControllerHub) UpdateTotalUsers

func (ch *ControllerHub) UpdateTotalUsers()

TODO: this method never ends

func (*ControllerHub) WriteInfluxPoint

func (ch *ControllerHub) WriteInfluxPoint(point *influx_write.Point) error

type EmojiMessage added in v0.3.0

type EmojiMessage struct {
	TargetType uint32  `json:"targetType"`
	TargetID   string  `json:"targetID"`
	Url        string  `json:"url"`
	EmojiID    string  `json:"emojiID"`
	X          float32 `json:"x"`
	Y          float32 `json:"y"`
	Z          float32 `json:"z"`
}

type LoadedSpaces

type LoadedSpaces struct {
	Time1    time.Duration
	Time2    time.Duration
	Time3    time.Duration
	Time4    time.Duration
	Time5    time.Duration
	Time6    time.Duration
	MetaTime time.Duration
	// contains filtered or unexported fields
}

func (*LoadedSpaces) Add

func (ls *LoadedSpaces) Add(obj *Space)

func (*LoadedSpaces) Delete

func (ls *LoadedSpaces) Delete(spaceId uuid.UUID)

func (*LoadedSpaces) FindClosest

func (ls *LoadedSpaces) FindClosest(pos *cmath.Vec3) (uuid.UUID, cmath.Vec3)

func (*LoadedSpaces) Get

func (ls *LoadedSpaces) Get(spaceId uuid.UUID) (*Space, bool)

func (*LoadedSpaces) GetPos

func (ls *LoadedSpaces) GetPos(id uuid.UUID) (cmath.Vec3, error)

func (*LoadedSpaces) GetPresent

func (ls *LoadedSpaces) GetPresent(spaceId uuid.UUID) (*Space, bool)

func (*LoadedSpaces) Init

func (ls *LoadedSpaces) Init()

func (*LoadedSpaces) Load

func (ls *LoadedSpaces) Load(req *RegRequest) *Space

func (*LoadedSpaces) LoadFromEntry

func (ls *LoadedSpaces) LoadFromEntry(req *RegRequest, entry map[string]interface{}) *Space

func (*LoadedSpaces) Num

func (ls *LoadedSpaces) Num() int

func (*LoadedSpaces) Unload

func (ls *LoadedSpaces) Unload(spaceId uuid.UUID) error

type RegRequest

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

type Space

type Space struct {
	Name string

	InfoUI uuid.UUID
	// contains filtered or unexported fields
}

func (*Space) AddSpaceTags added in v0.3.0

func (s *Space) AddSpaceTags(prefix string, p *write.Point) *write.Point

func (*Space) CalculateVibes

func (s *Space) CalculateVibes() (int64, error)

func (*Space) DeInit

func (s *Space) DeInit()

func (*Space) GetObjectDef added in v0.1.17

func (s *Space) GetObjectDef() *websocket.PreparedMessage

func (*Space) GetOnlineUsers

func (s *Space) GetOnlineUsers() (int64, error)

func (*Space) Init

func (s *Space) Init() error

func (*Space) MQTTEffectsHandler

func (s *Space) MQTTEffectsHandler(msg []byte)

func (*Space) MQTTMessageHandler

func (s *Space) MQTTMessageHandler(_ mqtt.Client, msg mqtt.Message)

func (*Space) RecursiveSendAllAttributes

func (s *Space) RecursiveSendAllAttributes(connection *socket.Connection)

func (*Space) RecursiveSendAllStrings

func (s *Space) RecursiveSendAllStrings(connection *socket.Connection)

func (*Space) RecursiveSendAllTextures

func (s *Space) RecursiveSendAllTextures(connection *socket.Connection)

func (*Space) SendToUsersOnSpace

func (s *Space) SendToUsersOnSpace(msg *websocket.PreparedMessage)

func (*Space) SetPosition

func (s *Space) SetPosition(pos cmath.Vec3)

func (*Space) UpdateChildren

func (s *Space) UpdateChildren() error

func (*Space) UpdateMeta

func (s *Space) UpdateMeta() error

func (*Space) UpdateMetaFromMap

func (s *Space) UpdateMetaFromMap(entry map[string]interface{}) error

func (*Space) UpdateObjectDef added in v0.1.17

func (s *Space) UpdateObjectDef()

func (*Space) UpdatePosition

func (s *Space) UpdatePosition(pos cmath.Vec3, theta float64, force bool) error

func (*Space) UpdateSpace

func (s *Space) UpdateSpace() error

type User

type User struct {
	ID        uuid.UUID
	SessionID uuid.UUID
	// contains filtered or unexported fields
}

func (*User) AddUserTags added in v0.3.0

func (u *User) AddUserTags(prefix string, p *write.Point) *write.Point

func (*User) CheckIfMegaMoji added in v0.3.0

func (u *User) CheckIfMegaMoji(emojiMessage *EmojiMessage, spaceID uuid.UUID, msg []byte) error

func (*User) HandleEmoji added in v0.3.0

func (u *User) HandleEmoji(m *posbus.RelayToController) error

func (*User) HandleHighFive

func (u *User) HandleHighFive(m *posbus.TriggerInteraction) error

func (*User) HandleSignals

func (u *User) HandleSignals(s posbus.Signal)

func (*User) HandleStake

func (u *User) HandleStake(m *posbus.TriggerInteraction)

func (*User) InteractionHandler

func (u *User) InteractionHandler(m *posbus.TriggerInteraction)

func (*User) MQTTMessageHandler

func (u *User) MQTTMessageHandler(_ mqtt.Client, msg mqtt.Message)

func (*User) OfflineAction added in v0.2.0

func (u *User) OfflineAction() error

func (*User) OnMessage

func (u *User) OnMessage(msg *posbus.Message)

func (*User) OnlineAction added in v0.2.0

func (u *User) OnlineAction() error

func (*User) Register

func (u *User) Register(wc *WorldController) error

func (*User) Send

func (u *User) Send(m *websocket.PreparedMessage)

func (*User) SendHighFiveStats added in v0.3.0

func (u *User) SendHighFiveStats(target *User) error

func (*User) SwitchWorld

func (u *User) SwitchWorld(newWorldId uuid.UUID) error

func (*User) Unregister

func (u *User) Unregister(h *WorldController) error

func (*User) UpdatePosition

func (u *User) UpdatePosition(data []byte)

type WorldController

type WorldController struct {
	ID uuid.UUID

	AdditionalExtensions map[string]extension.Extension
	MainExtension        extension.Extension
	EffectsEmitter       uuid.UUID
	Config               config.World

	EmojiJournals *utils.SyncMap[string, *emojiJournal]
	// contains filtered or unexported fields
}

WorldController ...

func (*WorldController) AddUserToWorld

func (wc *WorldController) AddUserToWorld(u *User) error

func (*WorldController) Broadcast

func (wc *WorldController) Broadcast(websocketMessage *websocket.PreparedMessage)

func (*WorldController) GetBuilder

func (wc *WorldController) GetBuilder() *message.Builder

func (*WorldController) GetConfig

func (wc *WorldController) GetConfig() *config.World

func (*WorldController) GetExtensionStorage

func (wc *WorldController) GetExtensionStorage() string

func (*WorldController) GetID added in v0.1.16

func (wc *WorldController) GetID() uuid.UUID

func (*WorldController) GetSpacePosition

func (wc *WorldController) GetSpacePosition(id uuid.UUID) (cmath.Vec3, error)

func (*WorldController) GetSpacePresent

func (wc *WorldController) GetSpacePresent(id uuid.UUID) bool

func (*WorldController) GetStorage

func (wc *WorldController) GetStorage() *storage.Database

func (*WorldController) InsertOnline

func (wc *WorldController) InsertOnline(id uuid.UUID) error

func (*WorldController) InsertWorldDynamicMembership

func (wc *WorldController) InsertWorldDynamicMembership(id uuid.UUID) error

func (*WorldController) LoadExtensions

func (wc *WorldController) LoadExtensions() error

func (*WorldController) PositionRelativeToAbsolute

func (wc *WorldController) PositionRelativeToAbsolute(spaceID uuid.UUID, v cmath.Vec3) (cmath.Vec3, error)

func (*WorldController) ProcessEmoji added in v0.3.0

func (wc *WorldController) ProcessEmoji(emoji string, pos *cmath.Vec3) (bool, cmath.Vec3)

ProcessEmoji : add emoji to the journal, remove from journal outdated entries calculate if there is a case for megaEmoji, and if it, returns true and average position of events inclided

func (*WorldController) SafeSubscribe

func (wc *WorldController) SafeSubscribe(topic string, qos byte, callback mqtt.MessageHandler)

func (*WorldController) SendSpaceData added in v0.1.17

func (wc *WorldController) SendSpaceData(spaceID uuid.UUID, u *User) error

func (*WorldController) SendWorldData added in v0.1.17

func (wc *WorldController) SendWorldData(u *User) error

func (*WorldController) SetSpaceTitle

func (wc *WorldController) SetSpaceTitle(spaceId uuid.UUID, title string) error

func (*WorldController) UpdateMeta

func (wc *WorldController) UpdateMeta() error

func (*WorldController) UpdateOnlineBySpaceId

func (wc *WorldController) UpdateOnlineBySpaceId(spaceId uuid.UUID) (int64, error)

func (*WorldController) UpdateVibesBySpaceId

func (wc *WorldController) UpdateVibesBySpaceId(spaceId uuid.UUID) (int64, error)

func (*WorldController) WriteInfluxPoint added in v0.3.0

func (wc *WorldController) WriteInfluxPoint(point *influx_write.Point) error

type WorldMeta

type WorldMeta struct {
	Name             string
	LODs             []uint32
	Decorations      []message.DecorationMetadata
	AvatarController uuid.UUID
	SkyboxController uuid.UUID
}

type WowMetadata

type WowMetadata struct {
	UserId  []string `json:"UserId"`
	WowType string   `json:"type"` // +1 -1
	Count   int      `json:"count"`
}

Jump to

Keyboard shortcuts

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