net

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Dec 3, 2018 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const RPC_PORT = 51832

RPC_PORT is the TCP port that the server listens to

Variables

This section is empty.

Functions

func AcceptCommands

func AcceptCommands(playerId string, connection *rpc.Client)

AcceptCommands takes a the UserID and RPC Client object and prompts the user for keyboard input. If the first token of the input matches a key in hashmap of commands their UserID and full input are sent to the server wrapped in ClientCommand struct. Response string from server is printed to screen.

func CreateServerConnection

func CreateServerConnection(username, password, address string) (string, *rpc.Client, error)

CreateServerConnection takes a username, password and network address and attempts to connect to a Game server running at that location. If a user using that username has never connected to that server before a Player is created on the server with the given username and password.

If a Player already exists on that server the password entered must be the password they entered when they first logged in or else they must re-login with a new username/password combo.

Upon successful login a string (their UserID) and the RPC Client object are returned, or an error.

func PrintMap

func PrintMap(boardSize uint8, icon func(x, y int) string) string

func PrintTeamCounts

func PrintTeamCounts(game *game.Game)

PrintTeamCounts prints a list of all the Teams and the number of users on each team

func RunServer

func RunServer(path string, maxPlayers, boardSize, shipLimit int, pass, adminPass string, deployPoints int, output chan Result)

func StartGameServer

func StartGameServer(newGame *game.Game)

StartGameServer creates the Server using a new Game, sets up the RPC Listener and handles all incoming Client requests.

Types

type ClientCommand

type ClientCommand struct {
	PlayerId string
	Fields   []string
}

ClientCommand wraps the PlayerID and command input into a single struct to send to server

type JoinDetails

type JoinDetails struct {
	PlayerId string
	TeamName string
}

JoinDetails is information sent back to the Client after a successful login telling the Client program their PlayerID and the team they've been assigned

type LoginCredentials

type LoginCredentials struct {
	Username string
	Password string
}

LoginCredentials is the Username/Password combo passed by the client when attempting to log in

type Result

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

type Server

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

Server is a struct exposed to clients and acts a buffer between clients and the actual Game

func (*Server) ChatHelp

func (t *Server) ChatHelp(args ClientCommand, response *string) error

func (*Server) Deploy

func (t *Server) Deploy(args ClientCommand, response *string) error

func (*Server) EchoTest

func (t *Server) EchoTest(args ClientCommand, response *string) error

EchoTest is used to confirm we are connected and the Client can send commands, the Server can receive them, and the Server can send a response that the Client can receive

func (*Server) JoinGame

func (t *Server) JoinGame(login LoginCredentials, info *JoinDetails) error

JoinGame joins a Player to the running Server using LoginCredentials.

func (*Server) Map

func (t *Server) Map(args ClientCommand, response *string) error

func (*Server) Mutiny

func (t *Server) Mutiny(args ClientCommand, response *string) error

Mutiny will start a new team and steal half the deployment points, but your score is reset to 10

func (*Server) Players

func (t *Server) Players(args ClientCommand, response *string) error

Players serves a list of Players on a given team# (team# based on Teams command)

func (*Server) Points

func (t *Server) Points(args ClientCommand, response *string) error

func (*Server) Radar

func (t *Server) Radar(args ClientCommand, response *string) error

func (*Server) Rename

func (t *Server) Rename(args ClientCommand, response *string) error

Rename a team

func (*Server) Shutdown

func (t *Server) Shutdown(args ClientCommand, response *string) error

func (*Server) Target

func (t *Server) Target(args ClientCommand, response *string) error

Target fires a shot

func (*Server) Teams

func (t *Server) Teams(args ClientCommand, response *string) error

Teams serves a list of all the Teams playing on this server, with a * in front of the calling Player's Team

Jump to

Keyboard shortcuts

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