models

package
v0.5.11 Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2024 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EntitiesToProtobuf

func EntitiesToProtobuf(entities []*Entity) []*hagallpb.Entity

func ParticipantsToProtobuf

func ParticipantsToProtobuf(participants []*Participant) []*hagallpb.Participant

Types

type Entity

type Entity struct {
	ID            uint32
	ParticipantID uint32
	Persist       bool
	Flag          hagallpb.EntityFlag
	// contains filtered or unexported fields
}

func (*Entity) Pose

func (e *Entity) Pose() Pose

func (*Entity) SetPose

func (e *Entity) SetPose(v Pose)

func (*Entity) ToProtobuf

func (e *Entity) ToProtobuf() *hagallpb.Entity

type EntityComponentHandler

type EntityComponentHandler func([]uint32)

type EntityComponentStore

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

func (*EntityComponentStore) Add

func (*EntityComponentStore) AddType

func (s *EntityComponentStore) AddType(name string) uint32

func (*EntityComponentStore) Delete

func (s *EntityComponentStore) Delete(entityComponentTypeID uint32, entityID uint32) bool

func (*EntityComponentStore) DeleteByEntityID

func (s *EntityComponentStore) DeleteByEntityID(entityID uint32)

func (*EntityComponentStore) GetTypeID

func (s *EntityComponentStore) GetTypeID(entityComponentTypeName string) (uint32, error)

func (*EntityComponentStore) GetTypeName

func (s *EntityComponentStore) GetTypeName(entityComponentTypeID uint32) (string, error)

func (*EntityComponentStore) List

func (s *EntityComponentStore) List(entityComponentTypeID uint32) []*hagallpb.EntityComponent

func (*EntityComponentStore) ListAll

func (*EntityComponentStore) ListByEntityID

func (s *EntityComponentStore) ListByEntityID(entityID uint32) []*hagallpb.EntityComponent

func (*EntityComponentStore) Notify

func (s *EntityComponentStore) Notify(entityComponentTypeID uint32, h EntityComponentHandler)

func (*EntityComponentStore) Subscribe

func (s *EntityComponentStore) Subscribe(entityComponentTypeID, participantID uint32) error

func (*EntityComponentStore) Unsubscribe

func (s *EntityComponentStore) Unsubscribe(entityComponentTypeID, participantID uint32)

func (*EntityComponentStore) UnsubscribeByParticipant

func (s *EntityComponentStore) UnsubscribeByParticipant(participantID uint32)

func (*EntityComponentStore) Update

type LatencyMetricsData added in v0.5.8

type LatencyMetricsData struct {
	Start time.Time
	End   time.Time
}

type Participant

type Participant struct {
	ID        uint32
	Responder hwebsocket.ResponseSender

	SignedLatency *SignedLatency
	// contains filtered or unexported fields
}

A session participant.

func (*Participant) AddEntity

func (p *Participant) AddEntity(e *Entity)

func (*Participant) EntityIDs

func (p *Participant) EntityIDs() map[uint32]struct{}

func (*Participant) RemoveEntity

func (p *Participant) RemoveEntity(e *Entity)

func (*Participant) ToProtobuf

func (p *Participant) ToProtobuf() *hagallpb.Participant

type Pose

type Pose struct {
	PX float32
	PY float32
	PZ float32
	RX float32
	RY float32
	RZ float32
	RW float32
}

func (Pose) ToProtobuf

func (p Pose) ToProtobuf() *hagallpb.Pose

type SequentialIDGenerator

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

A sequential id generator.

func (*SequentialIDGenerator) New

func (g *SequentialIDGenerator) New() uint32

New returns a sequental id.

func (*SequentialIDGenerator) Reuse

func (g *SequentialIDGenerator) Reuse(id uint32)

Reuse marks the given id as reusable. Reusable ids are returned in priority when using New.

type Session

type Session struct {
	ID          uint32
	SessionUUID string

	AppKey string
	// contains filtered or unexported fields
}

Session represents a session that contains entities and participants who can communicate between each other.

func NewSession

func NewSession(id uint32, frameDuration time.Duration) *Session

func (*Session) AddEntity

func (s *Session) AddEntity(e *Entity)

func (*Session) AddParticipant

func (s *Session) AddParticipant(p *Participant)

func (*Session) Broadcast

func (s *Session) Broadcast(sender *Participant, protoMsg hwebsocket.ProtoMsg)

func (*Session) BroadcastTo

func (s *Session) BroadcastTo(sender *Participant, protoMsg hwebsocket.ProtoMsg, participantIds ...uint32)

func (*Session) Close

func (s *Session) Close()

func (*Session) Entities

func (s *Session) Entities() []*Entity

func (*Session) EntityByID

func (s *Session) EntityByID(id uint32) (*Entity, bool)

func (*Session) GetEntityComponents

func (s *Session) GetEntityComponents() *EntityComponentStore

func (*Session) GetParticipants

func (s *Session) GetParticipants() []*Participant

func (*Session) GetParticipantsByIDs

func (s *Session) GetParticipantsByIDs(ids ...uint32) []*Participant

func (*Session) HandleFrame

func (s *Session) HandleFrame(h func()) (cancel func())

func (*Session) ModuleState

func (s *Session) ModuleState(moduleName string) (any, bool)

func (*Session) NewEntityID

func (s *Session) NewEntityID() uint32

func (*Session) NewParticipantID

func (s *Session) NewParticipantID() uint32

func (*Session) ParticipantCount

func (s *Session) ParticipantCount() int

func (*Session) RemoveEntity

func (s *Session) RemoveEntity(e *Entity)

func (*Session) RemoveParticipant

func (s *Session) RemoveParticipant(p *Participant)

func (*Session) SetModuleState

func (s *Session) SetModuleState(moduleName string, state any)

func (*Session) StartDispatchFrames

func (s *Session) StartDispatchFrames()

type SessionDiscoveryService

type SessionDiscoveryService interface {
	// Returns the id attributed to the current Hagall server.
	ServerID() string
}

SessionDiscoveryService is the interface to communicate with a session discovery service such as HDS.

type SessionStore

type SessionStore struct {
	// The session discovery service where sessions are registered.
	DiscoveryService SessionDiscoveryService
	// contains filtered or unexported fields
}

func (*SessionStore) Add

func (s *SessionStore) Add(ctx context.Context, session *Session) error

func (*SessionStore) GetByGlobalID

func (s *SessionStore) GetByGlobalID(v string) (*Session, bool)

func (*SessionStore) GlobalSessionID

func (s *SessionStore) GlobalSessionID(sessionID uint32) string

func (*SessionStore) NewID

func (s *SessionStore) NewID() uint32

func (*SessionStore) Remove

func (s *SessionStore) Remove(ctx context.Context, session *Session)

type SignedLatency added in v0.5.8

type SignedLatency struct {
	RequestID     uint32
	StartedAt     time.Time
	Iteration     uint32
	PingRequests  map[uint32]LatencyMetricsData
	SessionID     string
	ClientID      string
	WalletAddress string
	// contains filtered or unexported fields
}

func (*SignedLatency) OnPing added in v0.5.8

func (s *SignedLatency) OnPing(pingReqID uint32) error

func (*SignedLatency) Start added in v0.5.8

func (s *SignedLatency) Start(privateKey *ecdsa.PrivateKey, sender hwebsocket.ResponseSender, requestID, iteration uint32, sessionID, clientID, walletAddress string)

Jump to

Keyboard shortcuts

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