http

package
v0.0.0-...-0992052 Latest Latest
Warning

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

Go to latest
Published: Dec 1, 2017 License: GPL-3.0 Imports: 18 Imported by: 0

Documentation

Overview

Package http contain the http server.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Btoi

func Btoi(bs []byte) int

Btoi returns an 8-byte big endian representation of v.

Types

type CDb

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

CDb a client database.

func NewCdb

func NewCdb(file string) (cdb *CDb, err error)

NewCdb creates a new client database.

func (*CDb) BackupHandleFunc

func (cdb *CDb) BackupHandleFunc(w http.ResponseWriter, req *http.Request)

BackupHandleFunc handles http back up requests.

func (*CDb) Close

func (cdb *CDb) Close() error

Close closes the database.

func (*CDb) GetID

func (cdb *CDb) GetID(id int) (client *Client, isFound bool, err error)

GetID returns a client.

func (*CDb) GetName

func (cdb *CDb) GetName(name string) (client *Client, isFound bool, err error)

GetName returns a client.

func (*CDb) UpdDisable

func (cdb *CDb) UpdDisable(id int, isDisable bool) (name string, isUpd bool, err error)

UpdDisable update a clients disable field.

func (*CDb) UpdInsert

func (cdb *CDb) UpdInsert(inClient *Client) (updClient *Client, isUpd bool, err error)

UpdInsert inserts a client if it does not allready exist.

type Client

type Client struct {
	Name      string
	ID        int
	Pw        []byte
	IsDisable bool
	// contains filtered or unexported fields
}

Client the login object. Hold information of the user including loged-in information.

func NewClient

func NewClient(name string, pwTxt string) (client *Client, err error)

func (*Client) Copy

func (c *Client) Copy() *Client

Copy copies a client.

func (*Client) IsEqual

func (c *Client) IsEqual(o *Client) (isEqual bool)

IsEqual tests for equal.

type Clients

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

Clients the clients list.

func NewClients

func NewClients(games *games.Server) (clients *Clients, err error)

NewClients creates new clients.

func (*Clients) AddNew

func (clients *Clients) AddNew(name string, pwTxt string) (status login.Status, sid string, err error)

AddNew create and log-in a new client.

func (*Clients) CancelGameServer

func (clients *Clients) CancelGameServer() (err error)

CancelGameServer cancels the game server.

func (*Clients) Close

func (clients *Clients) Close() (err error)

Close closes clients database.

func (*Clients) IsGameServerDown

func (clients *Clients) IsGameServerDown() bool

IsGameServerDown checks if the game server is down.

func (*Clients) JoinGameServer

func (clients *Clients) JoinGameServer(name string, sid string, ws *websocket.Conn,
	errCh chan<- error, joinedCh chan<- *games.Player) (ok, isJoined bool)

JoinGameServer add a client to the game server. ok: True: if request succeded the player is returned on the joined channel when ready. isJoined: True: if the client is already loged-in.

func (*Clients) LogIn

func (clients *Clients) LogIn(name string, pw string) (status login.Status, sid string, err error)

LogIn log-in a client.

func (*Clients) LogOut

func (clients *Clients) LogOut(name string)

LogOut logs out the client.

func (*Clients) SetGameServer

func (clients *Clients) SetGameServer(games *games.Server) (oldGames *games.Server)

SetGameServer set the game server. The old game server is return, if set to nil all http server will return game server down. lock is used.

func (*Clients) UpdateDisable

func (clients *Clients) UpdateDisable(id int, isDisable bool) (err error)

UpdateDisable disable/enable a client.

func (*Clients) VerifySid

func (clients *Clients) VerifySid(name, sid string) (ok, isDown bool)

VerifySid verify name and session id, before ws is sat.

type ErrServer

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

ErrServer handles while the servers are running. All errors are send here so the error server can deside what to to do. Errors during close down does not need to be send here.

func NewErrServer

func NewErrServer(clients *Clients) (e *ErrServer)

NewErrServer creates a new error server

func (*ErrServer) Ch

func (e *ErrServer) Ch() chan<- error

Ch returns the channel errors should be send on.

func (*ErrServer) Start

func (e *ErrServer) Start()

Start starts the server.

func (*ErrServer) Stop

func (e *ErrServer) Stop()

Stop stopd the server.

type Server

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

Server a http server.

func New

func New(port, backupPort string, archPokePort int, archAddr, rootDir string) (s *Server, err error)

New creates a new Server.

func (*Server) Cancel

func (s *Server) Cancel() (err error)

Cancel cancels the server, if the server is created without errors it must be canceled or started.

func (*Server) Start

func (s *Server) Start()

Start starts the server.

func (*Server) Stop

func (s *Server) Stop()

Stop stops the server.

Directories

Path Synopsis
Package games contains the game server the games server consist of the tables server and players server.
Package games contains the game server the games server consist of the tables server and players server.

Jump to

Keyboard shortcuts

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