ws

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2024 License: GPL-3.0 Imports: 25 Imported by: 1

Documentation

Index

Constants

View Source
const (
	CloseOwnerLeft = "Owner Left"
	CloseDone      = "Read End"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func (*Client) Close

func (c *Client) Close()

Close closes the connection.

type ClientAnswer

type ClientAnswer outgoing.P2PMessage

func (*ClientAnswer) Execute

func (e *ClientAnswer) Execute(rooms *Rooms, current ClientInfo) error

type ClientICE

type ClientICE outgoing.P2PMessage

func (*ClientICE) Execute

func (e *ClientICE) Execute(rooms *Rooms, current ClientInfo) error

type ClientInfo

type ClientInfo struct {
	ID                xid.ID
	RoomID            string
	Authenticated     bool
	AuthenticatedUser string
	Write             chan outgoing.Message
	Close             chan string
	Addr              net.IP
}

type ClientMessage

type ClientMessage struct {
	Info     ClientInfo
	Incoming Event
}

type ConnectionMode

type ConnectionMode string
const (
	ConnectionLocal ConnectionMode = "local"
	ConnectionSTUN  ConnectionMode = "stun"
	ConnectionTURN  ConnectionMode = config.AuthModeTurn
)

type Create

type Create struct {
	ID                string         `json:"id"`
	Mode              ConnectionMode `json:"mode"`
	CloseOnOwnerLeave bool           `json:"closeOnOwnerLeave"`
	UserName          string         `json:"username"`
	JoinIfExist       bool           `json:"joinIfExist,omitempty"`
}

func (*Create) Execute

func (e *Create) Execute(rooms *Rooms, current ClientInfo) error

type Disconnected

type Disconnected struct{}

func (*Disconnected) Execute

func (e *Disconnected) Execute(rooms *Rooms, current ClientInfo) error

type Event

type Event interface {
	Execute(*Rooms, ClientInfo) error
}

func ReadTypedIncoming

func ReadTypedIncoming(r io.Reader) (Event, error)

type HostICE

type HostICE outgoing.P2PMessage

func (*HostICE) Execute

func (e *HostICE) Execute(rooms *Rooms, current ClientInfo) error

type HostOffer

type HostOffer outgoing.P2PMessage

func (*HostOffer) Execute

func (e *HostOffer) Execute(rooms *Rooms, current ClientInfo) error

type Join

type Join struct {
	ID       string `json:"id"`
	UserName string `json:"username,omitempty"`
}

func (*Join) Execute

func (e *Join) Execute(rooms *Rooms, current ClientInfo) error

type Name

type Name struct {
	UserName string `json:"username"`
}

func (*Name) Execute

func (e *Name) Execute(rooms *Rooms, current ClientInfo) error

type Room

type Room struct {
	ID                string
	CloseOnOwnerLeave bool
	Mode              ConnectionMode
	Users             map[xid.ID]*User
	Sessions          map[xid.ID]*RoomSession
}

type RoomSession

type RoomSession struct {
	Host   xid.ID
	Client xid.ID
}

type Rooms

type Rooms struct {
	Rooms    map[string]*Room
	Incoming chan ClientMessage
	// contains filtered or unexported fields
}

func NewRooms

func NewRooms(tServer turn.Server, users *auth.Users, conf config.Config) *Rooms

func (*Rooms) RandRoomName

func (r *Rooms) RandRoomName() string

func (*Rooms) RandUserName

func (r *Rooms) RandUserName() string

func (*Rooms) Start

func (r *Rooms) Start()

func (*Rooms) Upgrade

func (r *Rooms) Upgrade(w http.ResponseWriter, req *http.Request)

type StartShare

type StartShare struct{}

func (*StartShare) Execute

func (e *StartShare) Execute(rooms *Rooms, current ClientInfo) error

type StopShare

type StopShare struct{}

func (*StopShare) Execute

func (e *StopShare) Execute(rooms *Rooms, current ClientInfo) error

type Typed

type Typed struct {
	Type    string          `json:"type"`
	Payload json.RawMessage `json:"payload"`
}

func ToTypedOutgoing

func ToTypedOutgoing(outgoing outgoing.Message) (Typed, error)

type User

type User struct {
	ID        xid.ID
	Addr      net.IP
	Name      string
	Streaming bool
	Owner     bool
	Write     chan<- outgoing.Message
	Close     chan<- string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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