room

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client is a middleman between the websocket connection and the hub.

type ClientSetOrientationMessage

type ClientSetOrientationMessage struct {
	Position vector3.Float64 `json:"position"`
	Rotation vector4.Float64 `json:"rotation"`
}

type Hub

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

Hub maintains the set of active clients and broadcasts messages to the clients.

func NewHub

func NewHub(webScene *WebScene, modelVersion *int) *Hub

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) ServeWs

func (hub *Hub) ServeWs(w http.ResponseWriter, r *http.Request)

serveWs handles websocket requests from the peer.

type Message

type Message struct {
	Type MessageType     `json:"type"`
	Data json.RawMessage `json:"data"`
}

func (Message) ClientSetDisplayNameData

func (m Message) ClientSetDisplayNameData() string

func (Message) ClientSetOrientationData

func (m Message) ClientSetOrientationData() (ClientSetOrientationMessage, error)

func (Message) ClientSetSceneData

func (m Message) ClientSetSceneData() (WebScene, error)

type MessageType

type MessageType string
const (
	ClientSetOrientationMessageType MessageType = "Client-SetOrientation"
	ClientSetDisplayNameMessageType MessageType = "Client-SetDisplayName"
	ClientSetPointerMessageType     MessageType = "Client-SetPointer"
	ClientRemovePointerMessageType  MessageType = "Client-RemovePointer"
	ClientSetSceneMessageType       MessageType = "Client-SetScene"

	ServerSetClientIDMessageType       MessageType = "Server-SetClientID"
	ServerRoomStateUpdateMessageType   MessageType = "Server-RoomStateUpdate"
	ServerRefrershGeneratorMessageType MessageType = "Server-RefreshGenerator"
	ServerBroadcastMessageType         MessageType = "Server-Broadcast"
)

type Player

type Player struct {
	Name     string           `json:"name"`
	Position vector3.Float64  `json:"position"`
	Rotation vector4.Float64  `json:"rotation"`
	Pointer  *vector3.Float64 `json:"pointer,omitempty"`
}

type RoomState

type RoomState struct {
	Players      map[string]*Player
	WebScene     *WebScene
	ModelVersion int
}

type WebScene

type WebScene struct {
	RenderWireframe bool              `json:"renderWireframe"`
	AntiAlias       bool              `json:"antiAlias"`
	XrEnabled       bool              `json:"xrEnabled"`
	Fog             WebSceneFog       `json:"fog"`
	Background      coloring.WebColor `json:"background"`
	Lighting        coloring.WebColor `json:"lighting"`
	Ground          coloring.WebColor `json:"ground"`
}

func DefaultWebScene

func DefaultWebScene() *WebScene

type WebSceneFog

type WebSceneFog struct {
	Color coloring.WebColor `json:"color"`
	Near  float64           `json:"near"`
	Far   float64           `json:"far"`
}

Jump to

Keyboard shortcuts

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