Documentation ¶
Index ¶
- Variables
- type Authentication
- type Client
- type ClientManager
- func (cm *ClientManager) Add(sessionId uint32, outgoing Outgoing) *Client
- func (cm *ClientManager) Broadcast(messages ...P.Message)
- func (cm *ClientManager) Disconnect(c *Client, reason disconnectreason.ID)
- func (cm *ClientManager) FindClientByName(name string) *Client
- func (cm *ClientManager) ForEach(do func(c *Client))
- func (cm *ClientManager) GetClientByCN(cn uint32) *Client
- func (cm *ClientManager) GetClientByID(sessionId uint32) *Client
- func (cm *ClientManager) GetNumClients() (n int)
- func (cm *ClientManager) InformOthersOfJoin(c *Client)
- func (cm *ClientManager) Message(message string)
- func (cm *ClientManager) PrivilegedUsers() (privileged []*Client)
- func (cm *ClientManager) Relay(from *Client, messages ...P.Message)
- func (cm *ClientManager) SendToTeam(c *Client, messages ...P.Message)
- func (cm *ClientManager) UniqueName(c *Client) string
- type Config
- type Incoming
- type MapEdit
- type Outgoing
- type Server
- func (s *Server) AuthKick(client *Client, rol role.ID, domain, name string, victim *Client, ...)
- func (s *Server) Broadcast(messages ...P.Message)
- func (s *Server) BroadcastTime(seconds int)
- func (s *Server) ChangeMap(mode int32, map_ string)
- func (s *Server) ConfirmSpawn(client *Client, lifeSequence, _weapon int32)
- func (s *Server) Connect(sessionId uint32) (*Client, <-chan bool)
- func (s *Server) Disconnect(client *Client, reason disconnectreason.ID)
- func (s *Server) Empty()
- func (s *Server) EmptyMap()
- func (s *Server) ForEachPlayer(f func(p *game.Player))
- func (s *Server) ForceRespawn(target *Client)
- func (s *Server) GameDuration() time.Duration
- func (s *Server) HandleExplode(client *Client, millis int32, wpn weapon.Weapon, id int32, hits []hit)
- func (s *Server) HandlePacket(client *Client, channelID uint8, message P.Message)
- func (s *Server) HandleShoot(client *Client, wpn weapon.Weapon, id int32, from, to *geom.Vector, hits []hit)
- func (s *Server) Incoming() chan<- ServerPacket
- func (s *Server) Intermission()
- func (s *Server) Join(c *Client)
- func (s *Server) Kick(client *Client, victim *Client, reason string)
- func (s *Server) Leave(sessionId uint32)
- func (s *Server) MapChange()
- func (s *Server) Message(message string)
- func (s *Server) NumberOfPlayers() (n int)
- func (s *Server) Outgoing() <-chan ServerPacket
- func (s *Server) Pause()
- func (s *Server) Poll(ctx context.Context)
- func (s *Server) PrivilegedUsersPacket() (P.Message, bool)
- func (s *Server) ReceiveMaps() <-chan string
- func (s *Server) RefreshServerInfo()
- func (s *Server) RefreshTime()
- func (s *Server) ResetPlayers(resetFrags bool)
- func (s *Server) Resume()
- func (s *Server) SendWelcome(c *Client)
- func (s *Server) SetDescription(description string)
- func (s *Server) SetMap(map_ string)
- func (s *Server) SetMasterMode(c *Client, mm mastermode.ID)
- func (s *Server) SetMode(mode int32)
- func (s *Server) SetPublicServer(mm mastermode.ID)
- func (s *Server) Spawn(client *Client)
- func (s *Server) StartGame(mode game.Mode, mapname string)
- func (s *Server) StartMode(id gamemode.ID) game.Mode
- func (s *Server) TryJoin(c *Client, name string, playerModel int32, authDomain, authName string)
- func (s *Server) UniqueName(p *game.Player) string
- func (s *Server) Unsupervised()
- type ServerCommand
- type ServerCommands
- type ServerPacket
- type State
Constants ¶
This section is empty.
Variables ¶
var SetTimeLeft = &ServerCommand{ name: "settime", argsFormat: "[Xm][Ys]", aliases: []string{"time", "settimeleft", "settimeremaining", "timeleft", "timeremaining"}, description: "sets the time remaining to play to X minutes and Y seconds", minRole: role.Admin, f: func(s *Server, c *Client, args []string) { if len(args) < 1 { return } d, err := time.ParseDuration(args[0]) if err != nil { c.Message(cubecode.Error("could not parse duration: " + err.Error())) return } if d == 0 { d = 1 * time.Second s.Message(fmt.Sprintf("%s forced intermission", s.Clients.UniqueName(c))) } else { s.Message(fmt.Sprintf("%s set the time remaining to %s", s.Clients.UniqueName(c), d)) } s.Clock.SetTimeLeft(d) }, }
var ToggleCompetitiveMode = &ServerCommand{ name: "competitive", argsFormat: "0|1", aliases: []string{"comp"}, description: "in competitive mode, the server waits for all clients to load the map and auto-pauses when a player leaves the game", minRole: role.Master, f: func(s *Server, c *Client, args []string) { changed := false if len(args) >= 1 { val, err := strconv.Atoi(args[0]) if err != nil || (val != 0 && val != 1) { return } changed = s.CompetitiveMode != (val == 1) switch val { case 1: s.CompetitiveMode = true s.SetMasterMode(c, mastermode.Locked) default: s.CompetitiveMode = false } } if changed { if s.CompetitiveMode { s.Clients.Message("competitive mode will be enabled with next game") } else { s.Clients.Message("competitive mode will be disabled with next game") } } else { if s.CompetitiveMode { c.Message("competitive mode is on") } else { c.Message("competitive mode is off") } } }, }
var ToggleKeepTeams = &ServerCommand{ name: "keepteams", argsFormat: "0|1", aliases: []string{"persist", "persistteams"}, description: "keeps teams the same across map change", minRole: role.Master, f: func(s *Server, c *Client, args []string) { changed := false if len(args) >= 1 { val, err := strconv.Atoi(args[0]) if err != nil || (val != 0 && val != 1) { return } changed = s.KeepTeams != (val == 1) s.KeepTeams = val == 1 } if changed { if s.KeepTeams { s.Clients.Message("teams will be kept") } else { s.Clients.Message("teams will be shuffled") } } else { if s.KeepTeams { c.Message("teams will be kept") } else { c.Message("teams will be shuffled") } } }, }
var ToggleReportStats = &ServerCommand{ name: "reportstats", argsFormat: "0|1", aliases: []string{"repstats"}, description: "when enabled, end-game stats of players will be reported at intermission", minRole: role.Admin, f: func(s *Server, c *Client, args []string) { changed := false if len(args) >= 1 { val, err := strconv.Atoi(args[0]) if err != nil || (val != 0 && val != 1) { return } changed = s.ReportStats != (val == 1) s.ReportStats = val == 1 } if changed { if s.ReportStats { s.Clients.Message("stats will be reported at intermission") } else { s.Clients.Message("stats will not be reported") } } else { if s.ReportStats { c.Message("stats reporting is on") } else { c.Message("stats reporting is off") } } }, }
Functions ¶
This section is empty.
Types ¶
type Authentication ¶
type Authentication struct {
// contains filtered or unexported fields
}
type Client ¶
type Client struct { game.Player Role role.ID Joined bool // true if the player is actually in the game AuthRequiredBecause disconnectreason.ID // e.g. server is in private mode SessionID uint32 Ping int32 Positions *relay.Publisher Packets *relay.Publisher Authentications map[string]*Authentication // contains filtered or unexported fields }
Describes a client.
func (*Client) GrantMaster ¶
func (c *Client) GrantMaster()
func (*Client) RefreshWelcome ¶
func (c *Client) RefreshWelcome()
type ClientManager ¶
type ClientManager struct {
// contains filtered or unexported fields
}
func (*ClientManager) Add ¶
func (cm *ClientManager) Add(sessionId uint32, outgoing Outgoing) *Client
func (*ClientManager) Broadcast ¶
func (cm *ClientManager) Broadcast(messages ...P.Message)
Sends a packet to all clients currently in use.
func (*ClientManager) Disconnect ¶
func (cm *ClientManager) Disconnect(c *Client, reason disconnectreason.ID)
Tells other clients that the client disconnected, giving a disconnect reason in case it's not a normal leave.
func (*ClientManager) FindClientByName ¶
func (cm *ClientManager) FindClientByName(name string) *Client
func (*ClientManager) ForEach ¶
func (cm *ClientManager) ForEach(do func(c *Client))
func (*ClientManager) GetClientByCN ¶
func (cm *ClientManager) GetClientByCN(cn uint32) *Client
func (*ClientManager) GetClientByID ¶
func (cm *ClientManager) GetClientByID(sessionId uint32) *Client
func (*ClientManager) GetNumClients ¶
func (cm *ClientManager) GetNumClients() (n int)
Returns the number of connected clients.
func (*ClientManager) InformOthersOfJoin ¶
func (cm *ClientManager) InformOthersOfJoin(c *Client)
Informs all other clients that a client joined the game.
func (*ClientManager) Message ¶
func (cm *ClientManager) Message(message string)
func (*ClientManager) PrivilegedUsers ¶
func (cm *ClientManager) PrivilegedUsers() (privileged []*Client)
func (*ClientManager) SendToTeam ¶
func (cm *ClientManager) SendToTeam(c *Client, messages ...P.Message)
Send a packet to a client's team, but not the client himself, over the specified channel.
func (*ClientManager) UniqueName ¶
func (cm *ClientManager) UniqueName(c *Client) string
type Incoming ¶
type Incoming <-chan ServerPacket
type Outgoing ¶
type Outgoing chan<- ServerPacket
type Server ¶
type Server struct { utils.Session *Config *State Description string Clients *ClientManager Commands *commands.CommandGroup[*Client] Broadcasts *utils.Topic[[]P.Message] Edits *utils.Topic[MapEdit] // non-standard stuff KeepTeams bool CompetitiveMode bool ReportStats bool // contains filtered or unexported fields }
func (*Server) BroadcastTime ¶
func (*Server) ConfirmSpawn ¶
func (*Server) Disconnect ¶
func (s *Server) Disconnect(client *Client, reason disconnectreason.ID)
func (*Server) ForEachPlayer ¶
func (*Server) ForceRespawn ¶
Forcibly respawn a player. Passing nil respawns all non-spectating players.
func (*Server) GameDuration ¶
func (*Server) HandleExplode ¶
func (*Server) HandlePacket ¶
parses a packet and decides what to do based on the network message code at the front of the packet
func (*Server) HandleShoot ¶
func (*Server) Incoming ¶
func (s *Server) Incoming() chan<- ServerPacket
func (*Server) Intermission ¶
func (s *Server) Intermission()
func (*Server) Join ¶
Puts a client into the current game, using the data the client provided with his nmc.TryJoin packet.
func (*Server) NumberOfPlayers ¶
Returns the number of connected clients playing (i.e. joined and not spectating)
func (*Server) Outgoing ¶
func (s *Server) Outgoing() <-chan ServerPacket
func (*Server) ReceiveMaps ¶
func (*Server) RefreshServerInfo ¶
func (s *Server) RefreshServerInfo()
Send the server info to clients again, which updates the description on the scoreboard.
func (*Server) RefreshTime ¶
func (s *Server) RefreshTime()
func (*Server) ResetPlayers ¶
Kill all players, reset their scores (if resetFrags is true), and respawn them.
func (*Server) SendWelcome ¶
Sends 'welcome' information to a newly joined client like map, mode, time left, other players, etc.
func (*Server) SetDescription ¶
func (*Server) SetMasterMode ¶
func (s *Server) SetMasterMode(c *Client, mm mastermode.ID)
func (*Server) SetPublicServer ¶
func (s *Server) SetPublicServer(mm mastermode.ID)
func (*Server) Unsupervised ¶
func (s *Server) Unsupervised()
type ServerCommand ¶
type ServerCommand struct {
// contains filtered or unexported fields
}
func (*ServerCommand) Detailed ¶
func (cmd *ServerCommand) Detailed() string
func (*ServerCommand) String ¶
func (cmd *ServerCommand) String() string
type ServerCommands ¶
type ServerCommands struct {
// contains filtered or unexported fields
}
func NewCommands ¶
func NewCommands(s *Server, cmds ...*ServerCommand) *ServerCommands
func (*ServerCommands) Handle ¶
func (sc *ServerCommands) Handle(c *Client, msg string)
func (*ServerCommands) PrintCommands ¶
func (sc *ServerCommands) PrintCommands(c *Client)
func (*ServerCommands) Register ¶
func (sc *ServerCommands) Register(cmd *ServerCommand)
func (*ServerCommands) Unregister ¶
func (sc *ServerCommands) Unregister(cmd *ServerCommand)