server

package
v0.0.0-...-6440b20 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2014 License: MIT Imports: 22 Imported by: 1

Documentation

Index

Constants

View Source
const (
	PREPROCCESS_NONE   = iota
	PREPROCCESS_COFFEE = iota
	PREPROCCESS_LESS   = iota
	PREPROCCESS_UGLY   = iota
)
View Source
const (
	MODE_DEVELOPMENT = "development"
	MODE_PRODUCTION  = "production"

	GAME_PORT   = 9001
	CLIENT_PORT = 8080

	DEF_SLOTS = 0
)
View Source
const (
	CLOSE_NO_SLOTS      = 4502
	CLOSE_INVALID_PASS  = 4503
	CLOSE_INVALID_USER  = 4504
	CLOSE_INVALID_PROTO = 4505
)
View Source
const (
	PLAYER_LEFT       = iota
	PLAYER_DISCONNECT = iota

	GROUP_ALL = iota

	MESSAGE_INVALID = 0
	MESSAGE_CHAT    = 1
)
View Source
const (
	LOCATION_LOBBY = "lobby"
)

Variables

This section is empty.

Functions

func ChatMessage

func ChatMessage(from *Player, message string) []byte

func MessageType

func MessageType(message []byte) int

Types

type ChatMsg

type ChatMsg struct {
	MessageType int    `msgpack:"_t"`
	Name        string `msgpack:"n"`
	Message     string `msgpack:"m"`
	Server      bool   `msgpack:"s"`
	Error       bool   `msgpack:"e"`
}

type ClientConfig

type ClientConfig struct {
	SeedServers []SeedServer `json:"seed_servers"`
}

type ClientServer

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

func NewClientServer

func NewClientServer(conf ServerConfig) *ClientServer

func (*ClientServer) Serve

func (c *ClientServer) Serve()

type FlagConfig

type FlagConfig struct {
	Mode string

	HostName   string
	GamePort   int
	ClientPort int
	InfoPort   int

	ConfigFile string

	Register string
}
var Flags *FlagConfig

type GameServer

type GameServer struct {
	NoUsers int64

	GameLobby *Lobby
	// contains filtered or unexported fields
}

func NewGameServer

func NewGameServer(conf ServerConfig) (*GameServer, error)

func (*GameServer) Cleanup

func (g *GameServer) Cleanup()

func (*GameServer) RegisterWith

func (g *GameServer) RegisterWith(otherServer string) error

func (*GameServer) Serve

func (g *GameServer) Serve() error

func (*GameServer) ServerStatus

func (g *GameServer) ServerStatus()

type Lobby

type Lobby struct {
	*Room
}

func NewLobby

func NewLobby() *Lobby

func (*Lobby) Listen

func (l *Lobby) Listen()

func (*Lobby) Register

func (l *Lobby) Register(p *Player)

func (*Lobby) Unregister

func (l *Lobby) Unregister(p *Player, group, code int)

type Msg

type Msg struct {
	MessageType int `msgpack:"_t"`
}

type Player

type Player struct {
	User *datastore.User
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(ws *websocket.Conn, u *datastore.User) *Player

func (*Player) AddReader

func (p *Player) AddReader(pl PlayerReader)

func (*Player) Listen

func (p *Player) Listen()

func (*Player) RemoveReader

func (p *Player) RemoveReader(pl PlayerReader)

func (*Player) Unregister

func (p *Player) Unregister(group, code int)

func (*Player) Write

func (p *Player) Write(message []byte)

type PlayerMessage

type PlayerMessage struct {
	Player  *Player
	Message []byte
}

type PlayerReader

type PlayerReader interface {
	Channel() chan<- PlayerMessage
	Register(*Player)
	Unregister(*Player, int, int)
	Group() int
}

type Room

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

func NewRoom

func NewRoom(group int) *Room

func (*Room) Broadcast

func (r *Room) Broadcast(except *Player, message []byte)

func (*Room) Channel

func (r *Room) Channel() chan<- PlayerMessage

func (*Room) Group

func (r *Room) Group() int

func (*Room) Register

func (r *Room) Register(p *Player)

func (*Room) Unregister

func (r *Room) Unregister(p *Player, group, code int)

type SeedServer

type SeedServer struct {
	Hostname string `json:"hostname"`
	Port     int    `json:"port"`
}

type ServerConfig

type ServerConfig struct {
	Mode       string `yaml:"mode"`
	ServerName string `yaml:"name"`

	HostName      string `yaml:"hostname"`
	ListenAddress string `yaml:"listen_address"`
	GamePort      int    `yaml:"gameport"`
	ClientPort    int    `yaml:"clientport"`

	ClientAssets      string `yaml:"clientassets"`
	CompiledAssetPath string `yaml:"compiledassets"`

	CoffeePath string `yaml:"coffee"`
	LessPath   string `yaml:"less"`
	UglifyPath string `yaml:"uglify"`

	Slots     int  `yaml:"slots"`
	ForceAuth bool `yaml:"force_auth"`

	Origin []string `yaml:"origin"`

	Datastore     string            `yaml:"datastore"`
	DatastoreConf map[string]string `yaml:"datastore_conf"`

	SeedServers  []string `yaml:"seed_servers"`
	RegisterWith []string `yaml:"register_with"`

	TmpDir []string `yaml:"-"`

	Quit func() `yaml:"-"`
}

func ReadConfig

func ReadConfig() (ServerConfig, error)

func (ServerConfig) GetHostname

func (sc ServerConfig) GetHostname() string

Jump to

Keyboard shortcuts

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