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) 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 ¶
PlayerRoomInputCycle is the room cycle for a player. (after join a room this is the cycle for input)
func (*Player) ReadUsername ¶
ReadUsername block the user until an ok username is inserted
func (*Player) UpdateWebSocket ¶
UpdateWebSocket updates the websocket connection in the player
Click to show internal directories.
Click to hide internal directories.