server

package
v0.0.0-...-c522f26 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2017 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	GameStart  = "start"
	SelectCell = "selectCell"
	NexTurn    = "nextTurn"
	GameEnd    = "finish"
	PutFailed  = "putFailed"
)

Variables

This section is empty.

Functions

func DecodeMessage

func DecodeMessage(data []byte) (interface{}, error)

func SendGameEndMessage

func SendGameEndMessage(result gobang.GameProgressResult, gobang *gobang.Gobang) []byte

func SendGameStartMessage

func SendGameStartMessage(gobang *gobang.Gobang) []byte

func SendNextTurnMessage

func SendNextTurnMessage(gobang *gobang.Gobang) []byte

func SendPutFailedMessage

func SendPutFailedMessage(reason error) []byte

Types

type App

type App struct {
	*melody.Melody
	*logrus.Logger
	*GameContainer
}

func NewApp

func NewApp() *App

func (*App) Handler

func (app *App) Handler(c *gin.Context)

func (*App) OnConnect

func (app *App) OnConnect(s *melody.Session)

func (*App) OnDisconnect

func (app *App) OnDisconnect(s *melody.Session)

func (*App) OnMessage

func (app *App) OnMessage(s *melody.Session, msg []byte)

func (*App) Start

func (app *App) Start()

type CurrentGame

type CurrentGame struct {
	Game *gobang.Gobang `json:"game"`
}

type GameContainer

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

func NewGameContainer

func NewGameContainer() *GameContainer

func (*GameContainer) Lookup

func (c *GameContainer) Lookup(s *melody.Session) *gobang.Gobang

func (*GameContainer) Register

func (c *GameContainer) Register(s *melody.Session, game *gobang.Gobang)

func (*GameContainer) Unregister

func (c *GameContainer) Unregister(s *melody.Session)

type GameResult

type GameResult struct {
	Game   *gobang.Gobang            `json:"game"`
	Result gobang.GameProgressResult `json:"result"`
}

type GameStartMessage

type GameStartMessage struct {
	Stone gobang.Stone `json:"stone"`
}

type OutgoingMessage

type OutgoingMessage struct {
	Type string      `json:"type"`
	Body interface{} `json:"body"`
}

type ReceiveMessage

type ReceiveMessage struct {
	Type string          `json:"type"`
	Body json.RawMessage `json:"body"`
}

type SelectCellMessage

type SelectCellMessage struct {
	gobang.Point2D
}

type UnkownMessageError

type UnkownMessageError struct {
	*ReceiveMessage
}

func (*UnkownMessageError) Error

func (msg *UnkownMessageError) Error() string

Jump to

Keyboard shortcuts

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