gameserver

package
v0.0.0-...-ccc74db Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2021 License: LGPL-2.1 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//ActionMessageCreateRoom is the action to create a room
	ActionMessageCreateRoom actionMessageTypes = "CREATEROOM"
	//ActionMessageLeaveRoom is the action to leave a room
	ActionMessageLeaveRoom actionMessageTypes = "LEAVEROOM"
	//ActionMessageJoinRoom is the action to join a room
	ActionMessageJoinRoom actionMessageTypes = "JOINROOM"
	//ActionMessageMovement is the action to send a movement
	ActionMessageMovement actionMessageTypes = "MOVEMENT"
	//ActionListRooms is the action to request a list for all rooms
	ActionMessageListRooms actionMessageTypes = "LISTROOMS"
	//ActionMovesRoom is the message with the movements for all players
	ActionMessageMovesRoom actionMessageTypes = "MOVES"
	//ActionMessageLeaveRoomResponse is the response to a leaveroom message
	ActionMessageLeaveRoomResponse actionMessageTypes = "LEAVEROOMRESPONSE"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type GameServer

type GameServer struct {
	Instance *game.GameInstance
}

GameServer is a game server with rooms and other things...

func (GameServer) ManageRequest

func (gameServer GameServer) ManageRequest(w http.ResponseWriter, r *http.Request)

type Player

type Player struct {
	GameData          *game.PlayerGameData `json:"data"`
	GameInstance      *game.GameInstance
	RoomChannel       chan<- messaging.RoomMessageValue
	RoomChannelOutput <-chan messaging.RoomMessageValue
	IsInRoom          bool

	Conn           *websocket.Conn
	EndGameChannel chan bool
	EndPlayer      chan bool
	IsClosing      bool
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(instance *game.GameInstance) *Player

NewPlayer returns a new Player using a gameInstance instance

func (*Player) Close

func (p *Player) Close()

Close close the player handles

func (*Player) PlayerBroadcastListener

func (p *Player) PlayerBroadcastListener()

PlayerBroadcastListener is the listener for the broadcast messages from the gameInstance

func (*Player) PlayerCycle

func (p *Player) PlayerCycle()

PlayerCycle is the cycle of a player when not in the room

func (*Player) PlayerRoomGameCycle

func (p *Player) PlayerRoomGameCycle()

PlayerRoomGameCycle is the cycle for a single player that gets the messages from the server and write the message to the user

func (*Player) PlayerRoomInputCycle

func (p *Player) PlayerRoomInputCycle() error

PlayerRoomInputCycle is the room cycle for a player. (after join a room this is the cycle for input)

func (*Player) ReadUsername

func (p *Player) ReadUsername() error

ReadUsername block the user until an ok username is inserted

func (*Player) UpdateWebSocket

func (p *Player) UpdateWebSocket(conn *websocket.Conn)

UpdateWebSocket updates the websocket connection in the player

Jump to

Keyboard shortcuts

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