domain

package
v0.0.0-...-9fea623 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2016 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Comm

type Comm interface {
	// Id returns the session id of socket.
	Id() string
	// Rooms returns the rooms name joined now.
	Rooms() []string
	// On registers the function f to handle an event.
	On(event string, f interface{}) error
	// Emit emits an event with given args.
	Emit(event string, args ...interface{}) error
	// Join joins the room.
	Join(room string) error
	// Leave leaves the room.
	Leave(room string) error
	// BroadcastTo broadcasts an event to the room with given args.
	BroadcastTo(room, event string, args ...interface{}) error
}

Comm provides an interface to communicate with the Player

type Game

type Game struct {
	FileName   string `toml:"-"`
	Lobby      *Lobby
	MinPlayers int    `toml:"minPlayers"`
	MaxPlayers int    `toml:"maxPlayers"`
	Title      string `toml:"displayTitle"`
	UUID       string `toml:"uniqueKey"`
}

Game contains all of our registered game information

type GameMap

type GameMap map[string]Game

GameMap serves as an in memory store of the different registered games

type Lobby

type Lobby struct {
	Protect *sync.RWMutex
	// contains filtered or unexported fields
}

Lobby is basically a FIFO queue that is threadsafe through the usage of mutex it uses a slice as the data store and a string to bool map to keep of track of items in the queue

func NewLobby

func NewLobby() *Lobby

NewLobby instantiates a new lobby (queue)

func (*Lobby) AddToQueue

func (l *Lobby) AddToQueue(p Player)

AddToQueue adds a player to the queue

func (*Lobby) Contains

func (l *Lobby) Contains(id string) bool

Contains returns true if the q contains the player with the given id

func (*Lobby) PopFromQueue

func (l *Lobby) PopFromQueue() Player

PopFromQueue returns a player from the queue: FIFO

func (*Lobby) Remove

func (l *Lobby) Remove(id string)

Remove removes the player with the specified id

func (*Lobby) Size

func (l *Lobby) Size() int

Size returns the number of items in the q

type Player

type Player struct {
	Comm Comm
}

Player ..

func (Player) String

func (p Player) String() string

type PlayerStore

type PlayerStore interface {
	Store(p Player)
	Get(uuid string) (*Player, error)
}

PlayerStore ...

Jump to

Keyboard shortcuts

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