server

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: MIT Imports: 11 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(l net.Listener, path string)

func WsHandler

func WsHandler(w http.ResponseWriter, r *http.Request)

Types

type Connection

type Connection struct {
	ID     uuid.UUID
	RoomID string
	// contains filtered or unexported fields
}

func (*Connection) Listen

func (connection *Connection) Listen(room *Room, shutdownCtx context.Context)

func (*Connection) PingLoop

func (connection *Connection) PingLoop(room *Room, shutdownCtx context.Context)

type Room

type Room struct {
	ID          string
	OwnerID     uuid.UUID
	Connections map[uuid.UUID]*Connection
	sync.Mutex

	Ready chan struct{}
	// contains filtered or unexported fields
}

func (*Room) Delete

func (room *Room) Delete(id uuid.UUID)

func (*Room) GetConnection

func (room *Room) GetConnection(id uuid.UUID) (*Connection, bool)

func (*Room) NewConnection

func (room *Room) NewConnection(owner bool, conn *websocket.Conn)

making a new owner connection marks the room as ready

func (*Room) WriteToWebsocket

func (room *Room) WriteToWebsocket(id uuid.UUID, msg message.Msg)

write a message to the target's websocket. if we are sending to the owner, and the write fails, we shutdown the room

Jump to

Keyboard shortcuts

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