room

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: May 11, 2024 License: MIT Imports: 14 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 {

	// config
	Config *ClientConfig
	// contains filtered or unexported fields
}

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

type ClientConfig added in v0.11.0

type ClientConfig struct {
	// Time allowed to write a message to the peer.
	WriteWait time.Duration

	// Time allowed to read the next pong message from the peer.
	PongWait time.Duration

	// Send pings to peer with this period. Must be less than pongWait.
	PingPeriod time.Duration

	// Maximum message size allowed from peer.
	MaxMessageSize int64
}

func DefaultClientConfig added in v0.11.0

func DefaultClientConfig() *ClientConfig

type ClientSetOrientationMessage

type ClientSetOrientationMessage struct {
	Objects []PlayerRepresentation
}

type Hub

type Hub struct {
	ClientConfig *ClientConfig
	// 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 *uint32) *Hub

func (*Hub) Run

func (h *Hub) Run()

func (*Hub) ServeWs

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

serveWs handles websocket requests from the peer.

type Message

type Message struct {
	Type MessageType
	Data []byte
}

func MessageFromClient added in v0.11.0

func MessageFromClient(data []byte) Message

func ServerRoomStateUpdate added in v0.11.0

func ServerRoomStateUpdate(room RoomState) Message

func SeverSetClientIDMessage added in v0.11.0

func SeverSetClientIDMessage(id string) Message

func (Message) ClientSetDisplayName added in v0.11.0

func (m Message) ClientSetDisplayName() string

func (Message) ClientSetOrientation added in v0.11.0

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

func (Message) ClientSetScene added in v0.11.0

func (m Message) ClientSetScene() json.RawMessage

func (Message) ClientSetSceneData

func (m Message) ClientSetSceneData() WebScene

func (Message) ServerRoomStateUpdate added in v0.11.0

func (m Message) ServerRoomStateUpdate() RoomState

func (Message) SeverSetClientID added in v0.11.0

func (m Message) SeverSetClientID() string

func (Message) Write added in v0.11.0

func (m Message) Write(out io.Writer) error

type MessageType

type MessageType byte
const (
	ClientSetOrientationMessageType MessageType = 0
	ClientSetDisplayNameMessageType MessageType = 1
	ClientSetSceneMessageType       MessageType = 2
	ClientSetPointerMessageType     MessageType = 3
	ClientRemovePointerMessageType  MessageType = 4

	ServerSetClientIDMessageType       MessageType = 0 + 128
	ServerRoomStateUpdateMessageType   MessageType = 1 + 128
	ServerRefrershGeneratorMessageType MessageType = 2 + 128
	ServerBroadcastMessageType         MessageType = 3 + 128
)

type Player

type Player struct {
	Name           string                 `json:"name"`
	Representation []PlayerRepresentation `json:"representation"`
}

type PlayerRepresentation added in v0.11.0

type PlayerRepresentation struct {
	Type     byte          `json:"type"`
	Position Vec3[float32] `json:"position"`
	Rotation Vec4[float32] `json:"rotation"`
}

type RoomState

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

type Vec3 added in v0.11.0

type Vec3[T vector.Number] struct {
	X T
	Y T
	Z T
}

type Vec4 added in v0.11.0

type Vec4[T vector.Number] struct {
	X T
	Y T
	Z T
	W T
}

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  float32           `json:"near"`
	Far   float32           `json:"far"`
}

Jump to

Keyboard shortcuts

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