Documentation ¶
Index ¶
- Constants
- func InitClientData()
- type Client
- func (c *Client) Close()
- func (c *Client) FireClientClose(event ClientEvent) SocketEvent
- func (c *Client) FireClientCommand(event ClientEvent) SocketEvent
- func (c *Client) FireClose() ClientEvent
- func (c *Client) GetClientType() string
- func (c *Client) SendPacket(pkt []byte) error
- func (c *Client) WriteEncode(packet *codec.Answer) error
- type ClientData
- type ClientEvent
- type EventClientCommand
- type PlayerData
- type ServerData
- type Socket
- type SocketEvent
- type SocketUDP
- type SocketUDPEvent
Constants ¶
const ( // RegionAsia - NRT stands for Narita Airport, Tokyo, Japan RegionAsia = "nrt" // RegionEurope - GVA stands for Geneve Airport, Switzerland RegionEurope = "gva" // RegionEastCoast - IAD stands for Dulles Airport, WA, USA RegionEastCoast = "iad" // RegionWestCoast - SJC stands for San Jose Airport, CA, USA RegionWestCoast = "sjc" )
const ( // FragmentSize is defined in fsys.Hello which specifies // how many bytes can be in one packet sent over the backend. // // TODO: Use value specified in fsys.Hello instead of this hardcoded const FragmentSize = 8096 )
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct { Conn net.Conn IsActive bool IpAddr net.Addr HeartTicker *time.Ticker // Type defines a what type of executable client defines this connection // i.e. "server", "client-nonreg" Type string PlayerData *PlayerData ServerData ServerData // contains filtered or unexported fields }
func NewClientTCP ¶
func NewClientTLS ¶
func (*Client) FireClientClose ¶
func (c *Client) FireClientClose(event ClientEvent) SocketEvent
func (*Client) FireClientCommand ¶
func (c *Client) FireClientCommand(event ClientEvent) SocketEvent
func (*Client) FireClose ¶
func (c *Client) FireClose() ClientEvent
func (*Client) GetClientType ¶
func (*Client) SendPacket ¶
type ClientData ¶
type ClientData struct { Store map[string]*PlayerData // contains filtered or unexported fields }
var (
Lobby *ClientData
)
func (*ClientData) Add ¶
func (s *ClientData) Add(lkey string, pd *PlayerData) error
func (*ClientData) Delete ¶
func (s *ClientData) Delete(lkey string)
func (*ClientData) Get ¶
func (s *ClientData) Get(lkey string) (*PlayerData, error)
type ClientEvent ¶
type ClientEvent struct { Name string Data interface{} }
ClientEvent is the generic struct for events by this Client
type EventClientCommand ¶
type PlayerData ¶
type ServerData ¶
ServerData contains such keys as:
Custom: * "AP"
CGAM: * "B-U-alwaysQueue" * "B-U-army_balance" * "B-U-army_distribution" * "B-U-avail_slots_national" * "B-U-avail_slots_royal" * "B-U-avg_ally_rank" * "B-U-avg_axis_rank" * "B-U-community_name" * "B-U-data_center" * "B-U-elo_rank" * "B-U-map" * "B-U-percent_full" * "B-U-server_ip" * "B-U-server_port" * "B-U-server_state" * "B-maxObservers" * "B-numObservers" * "B-version" * "DISABLE-AUTO-DEQUEUE" * "HTTYPE" * "HXFR" * "INT-IP" * "INT-PORT" * "JOIN" * "LID" * "MAX-PLAYERS" * "NAME" * "PORT" * "QLEN" * "RESERVE-HOST" * "RT" * "SECRET" * "TID" * "TYPE" * "UGID"
UGAM: (The same as in CGAM)
func (ServerData) Get ¶
func (sd ServerData) Get(key string) string
func (ServerData) Set ¶
func (sd ServerData) Set(key, value string)
type Socket ¶
type Socket struct { EventChan chan SocketEvent // contains filtered or unexported fields }
Socket is a basic event-based TCP-Server TODO: Rename it to broker
func NewSocketTCP ¶
func NewSocketTLS ¶
func (*Socket) Close ¶
func (socket *Socket) Close()
Close fires a close-event and closes the socket
func (*Socket) FireNewClient ¶
func (s *Socket) FireNewClient(c *Client) SocketEvent
type SocketEvent ¶
type SocketEvent struct { Name string Data interface{} }
SocketEvent is the generic struct for events by this socket
Current events:
Name -> Data-Type close -> nil error -> error newClient -> *Client client.close -> [0: *client, 1:nil] client.error -> {*client, error} client.command.* -> {*client, *Command} client.data -> {*client, string}
type SocketUDP ¶
type SocketUDP struct { EventChan chan SocketUDPEvent // contains filtered or unexported fields }