session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 27, 2022 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ControllerRegistry = controllerRegistry{}
View Source
var Registry = &registry{
	sessions: make(map[string]*Session),
	stop:     make(chan bool),
	logger:   logger.Logger.With().Str("service", "sessionManager").Logger(),
}

Functions

This section is empty.

Types

type Controller

type Controller interface {
	// Name returns the name of the controller. If multiple controllers of the same name are registered with the world
	// then the last one registered will be used. This enables the developer to override specific controllers with their
	// own implementation.
	Name() string

	// Start is called when the controller is set.
	Start(session Session) error

	// Resume called when the world restarts, causing the portal to reset-assert the session.
	Resume(session Session) error

	// Stop is called when the controller is unset.
	Stop(session Session) error

	// HandleInput is called when the player sends input to the world.
	HandleInput(session Session, input string) error
}

Controller is the interface for a session controller. A session controller handles interactions from the player session to the game world

type Session

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

Session represents the link between the world and portal.

func New

func New(e *events.AssertSession) *Session

func (Session) Context

func (s Session) Context() context.Context

func (Session) GetController

func (s Session) GetController() (Controller, error)

GetController returns the current controller or an error if a controller of that controller does not exist

func (Session) GetIntFromFlash

func (s Session) GetIntFromFlash(key string) int

func (Session) GetIntFromStore

func (s Session) GetIntFromStore(key string) int

func (Session) GetStringFromFlash

func (s Session) GetStringFromFlash(key string) string

func (Session) GetStringFromStore

func (s Session) GetStringFromStore(key string) string

func (Session) ID

func (s Session) ID() string

func (Session) Logger

func (s Session) Logger() *zerolog.Logger

func (Session) Resume

func (s Session) Resume()

func (Session) SetController

func (s Session) SetController(name string)

func (Session) SetInFlash

func (s Session) SetInFlash(key string, value interface{})

func (Session) SetInStore

func (s Session) SetInStore(key string, value interface{})

func (Session) SetStringInStore

func (s Session) SetStringInStore(key string, value string)

func (Session) Start

func (s Session) Start()

func (Session) Stop

func (s Session) Stop()

func (Session) WriteToConnection

func (s Session) WriteToConnection(data string)

WriteToConnection writes the given string to the connection. It breaks it up by lines and sends each line to the connection. If an error occurs, it will stop the session.

func (Session) WriteToConnectionF

func (s Session) WriteToConnectionF(format string, args ...interface{})

Jump to

Keyboard shortcuts

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