sessions

package
v0.0.0-...-ebe70a3 Latest Latest
Warning

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

Go to latest
Published: Jun 2, 2020 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// FlagKeyExchanged indicates the key exchange process has completed
	FlagKeyExchanged = 0x1
	// FlagEncrypted indicates the transmission of this session is encrypted
	FlagEncrypted = 0x2
	// FlagKicked indicates the client has been kicked out
	FlagKicked = 0x4
	// FlagAuth indicates the session has been authorized
	FlagAuth = 0x8
)

Variables

This section is empty.

Functions

func UseLogger

func UseLogger(l *zap.Logger)

UseLogger set logger for this sub-system

Types

type Flag

type Flag int32

Flag holds session status flag bits

type Session

type Session struct {
	UID       uint64        // User id
	LastLogin uint64        // Timestamp of last time login
	Token     string        // Session token generate at http login
	Die       chan struct{} // Session close signal, trigger by agent()

	IP                net.IP        // Client IP address
	Port              string        // Client Port
	Client            *game.Client  // Client in game server
	Encoder           *rc4.Cipher   // Encrypt
	Decoder           *rc4.Cipher   // Decrypt
	ClientSeq         uint64        // incoming packet sequence
	ServerSeq         uint64        // outgoing sequence
	Push              chan []byte   // Push channel for internal communication
	MQ                chan pb.Frame // MQ queue for packets from game
	ConnectTime       time.Time     // Timestamp of TCP connection established
	LastPacketTime    time.Time     // Timestamp of last packet arrived
	PacketCount       int           // Total packets received
	PacketCountPerMin int           // Packets received per minute
	RPMLimit          int           // Request per minute limit
	// contains filtered or unexported fields
}

Session holds the context of a client having conversation with agent

func New

func New(ip net.IP, port string, rpmLimit int) *Session

New returns a new session instance

func (*Session) CheckRPMLimitViolation

func (s *Session) CheckRPMLimitViolation() bool

CheckRPMLimitViolation returns true if session violates RPM limitation

func (*Session) ClearFlagAuth

func (s *Session) ClearFlagAuth() *Session

ClearFlagAuth clears the auth bit

func (*Session) ClearFlagEncrypted

func (s *Session) ClearFlagEncrypted() *Session

ClearFlagEncrypted clears the encrypted bit

func (*Session) ClearFlagKeyExchanged

func (s *Session) ClearFlagKeyExchanged() *Session

ClearFlagKeyExchanged clears the key exchanged bit

func (*Session) ClearFlagKicked

func (s *Session) ClearFlagKicked() *Session

ClearFlagKicked clears the kicked bit

func (*Session) ErrorResponse

func (s *Session) ErrorResponse(cmd int32, status int32, msg string) []byte

ErrorResponse create a S2CHeader and fill with error information, then return its marshaled data

func (*Session) FetchLoop

func (s *Session) FetchLoop()

FetchLoop fetches streams from game service

func (*Session) Flag

func (s *Session) Flag() Flag

Flag return session's flag

func (*Session) IsFlagAuthSet

func (s *Session) IsFlagAuthSet() bool

IsFlagAuthSet returns true if the auth bit is set

func (*Session) IsFlagEncryptedSet

func (s *Session) IsFlagEncryptedSet() bool

IsFlagEncryptedSet returns true if the encrypted bit is set

func (*Session) IsFlagKeyExchangedSet

func (s *Session) IsFlagKeyExchangedSet() bool

IsFlagKeyExchangedSet return true if the key exchanged bit is set

func (*Session) IsFlagKickedSet

func (s *Session) IsFlagKickedSet() bool

IsFlagKickedSet returns true if the kicked bit is set

func (*Session) NextSeq

func (s *Session) NextSeq() uint64

NextSeq return next packet sequence number

func (*Session) Response

func (s *Session) Response(cmd int32, body []byte) []byte

Response create a S2CHeader and fill with response cmd and body

func (*Session) SetFlagAuth

func (s *Session) SetFlagAuth() *Session

SetFlagAuth sets the auth bit

func (*Session) SetFlagEncrypted

func (s *Session) SetFlagEncrypted() *Session

SetFlagEncrypted sets the encrypted bit

func (*Session) SetFlagKeyExchanged

func (s *Session) SetFlagKeyExchanged() *Session

SetFlagKeyExchanged sets the key exchanged bit

func (*Session) SetFlagKicked

func (s *Session) SetFlagKicked() *Session

SetFlagKicked sets the kicked bit

func (*Session) String

func (s *Session) String() string

String interface

Jump to

Keyboard shortcuts

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