network

package
v0.0.0-...-0379cd4 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2018 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
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"
)
View Source
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

func InitClientData

func InitClientData()

FIXME: Debug only

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 NewClientTCP(conn net.Conn) *Client

func NewClientTLS

func NewClientTLS(conn *tls.Conn) *Client

func (*Client) Close

func (c *Client) Close()

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 (c *Client) GetClientType() string

func (*Client) SendPacket

func (c *Client) SendPacket(pkt []byte) error

func (*Client) WriteEncode

func (c *Client) WriteEncode(packet *codec.Answer) error

type ClientData

type ClientData struct {
	Store map[string]*PlayerData
	// contains filtered or unexported fields
}
var (
	Lobby *ClientData
)

func NewClientData

func NewClientData() *ClientData

WARNING: It is only for debugging purposes!

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 EventClientCommand struct {
	Client *Client
	// If TLS (theater then we ignore payloadID - it is always 0x0)
	Command *codec.Command
}

type PlayerData

type PlayerData struct {
	LobbyKey   string
	ClientName string

	PlayerID int
	HeroID   int
	HeroName string

	ServerID          int
	ServerSoldierName string
	ServerUserName    string
	GameID            int
}

type ServerData

type ServerData map[string]string

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 NewSocketTCP(bind string) (*Socket, error)

func NewSocketTLS

func NewSocketTLS(bind string) (*Socket, error)

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
}

func NewSocketUDP

func NewSocketUDP(bind string) (*SocketUDP, error)

func (*SocketUDP) Close

func (socket *SocketUDP) Close()

Close fires a close-event and closes the socket

func (*SocketUDP) WriteEncode

func (socket *SocketUDP) WriteEncode(packet *codec.Answer, addr *net.UDPAddr) error

type SocketUDPEvent

type SocketUDPEvent struct {
	Name string
	Addr *net.UDPAddr
	Data interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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