user

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Rendered for js/wasm

Overview

Package user contains code to create and edit users that can play games in the lobby.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DOM added in v1.2.0

type DOM interface {
	QuerySelector(query string) js.Value
	QuerySelectorAll(document js.Value, query string) []js.Value
	Checked(query string) bool
	SetChecked(query string, checked bool)
	Value(query string) string
	SetValue(query, value string)
	Confirm(message string) bool
	NewXHR() js.Value
	Base64Decode(a string) []byte
	StoreCredentials(form js.Value)
	EncodeURIComponent(str string) string
	RegisterFuncs(ctx context.Context, wg *sync.WaitGroup, parentName string, jsFuncs map[string]js.Func)
	NewJsEventFunc(fn func(event js.Value)) js.Func
	NewJsEventFuncAsync(fn func(event js.Value), async bool) js.Func
}

DOM interacts with the page.

type HTTPRequester added in v1.2.0

type HTTPRequester interface {
	Do(dom http.DOM, req http.Request) (*http.Response, error)
}

HTTPRequester does HTTP requests.

type Log added in v1.2.0

type Log interface {
	Error(text string)
	Warning(text string)
	Clear()
}

Log is used to store text about connection errors.

type Socket

type Socket interface {
	Close()
}

Socket is a structure that the user interacts with for the lobby and game.

type User

type User struct {
	Socket Socket
	// contains filtered or unexported fields
}

User is a http/login helper.

func New

func New(dom DOM, log Log, httpClient HTTPRequester) *User

New creates a http/login helper struct.

func (*User) InitDom

func (u *User) InitDom(ctx context.Context, wg *sync.WaitGroup)

InitDom registers user dom functions.

func (User) JWT

func (u User) JWT() string

JWT gets the value of the jwt input.

func (*User) Logout

func (u *User) Logout()

Logout logs out the user.

func (User) Username

func (u User) Username() string

Username returns the username of the logged in user. If any problem occurs, an empty string is returned.

Jump to

Keyboard shortcuts

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