server

package
v0.85.0 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2022 License: Apache-2.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	STATE_ERROR              = 0x0000
	STATE_CONNECTED2         = 0x0100
	STATE_HANDSHAKE          = 0x0200
	STATE_pq                 = 0x0201
	STATE_pq_res             = 0x0202
	STATE_pq_ack             = 0x0203
	STATE_DH_params          = 0x0204
	STATE_DH_params_res      = 0x0205
	STATE_DH_params_res_fail = 0x0206
	STATE_DH_params_ack      = 0x0207
	STATE_dh_gen             = 0x0208
	STATE_dh_gen_res         = 0x0209
	STATE_dh_gen_res_retry   = 0x020a
	STATE_dh_gen_res_fail    = 0x020b
	STATE_dh_gen_ack         = 0x020c
	STATE_AUTH_KEY           = 0x0300
)
View Source
const (
	RES_STATE_NONE  = 0x00
	RES_STATE_OK    = 0x01
	RES_STATE_ERROR = 0x02
)
View Source
const (
	SHA_DIGEST_LENGTH = 20
)

Variables

View Source
var (
	ErrSessionNotFound = errors.New("not found session")
)

Functions

func NewAuthSessionManager

func NewAuthSessionManager() *authSessionManager

Types

type Logger

type Logger struct {
	logx.Logger
}

func NewLogger

func NewLogger() Logger

type Server

type Server struct {
	*gnet.EventServer
	// contains filtered or unexported fields
}

func New

func New(c config.Config) *Server

func (*Server) Close

func (s *Server) Close()

func (*Server) GatewaySendDataToGateway

func (s *Server) GatewaySendDataToGateway(ctx context.Context, in *gateway.TLGatewaySendDataToGateway) (reply *mtproto.Bool, err error)

GatewaySendDataToGateway gateway.sendDataToGateway auth_key_id:long session_id:long payload:bytes = Bool;

func (*Server) GetAuthKey

func (s *Server) GetAuthKey(authKeyId int64) *mtproto.AuthKeyInfo

func (*Server) GetConnCounts

func (s *Server) GetConnCounts() int

func (*Server) OnClosed

func (s *Server) OnClosed(c gnet.Conn, err error) (action gnet.Action)

OnClosed fires when a connection has been closed. The parameter:err is the last known connection error.

func (*Server) OnInitComplete

func (s *Server) OnInitComplete(svr gnet.Server) (action gnet.Action)

OnInitComplete fires when the server is ready for accepting connections. The parameter:server has information and various utilities.

func (*Server) OnOpened

func (s *Server) OnOpened(c gnet.Conn) (out []byte, action gnet.Action)

OnOpened fires when a new connection has been opened. The parameter:c has information about the connection such as it's local and remote address. Parameter:out is the return value which is going to be sent back to the client.

func (*Server) OnShutdown

func (s *Server) OnShutdown(svr gnet.Server)

OnShutdown fires when the server is being shut down, it is called right after all event-loops and connections are closed.

func (*Server) Ping

func (s *Server) Ping(ctx context.Context) (err error)

Ping ping the resource.

func (*Server) PreWrite

func (s *Server) PreWrite(c gnet.Conn)

PreWrite fires just before any data is written to any client socket, this event function is usually used to put some code of logging/counting/reporting or any prepositive operations before writing data to client.

func (*Server) PutAuthKey

func (s *Server) PutAuthKey(keyInfo *mtproto.AuthKeyInfo)

func (*Server) React

func (s *Server) React(frame interface{}, c gnet.Conn) (out interface{}, action gnet.Action)

React fires when a connection sends the server data. Call c.Read() or c.ReadN(n) within the parameter:c to read incoming data from client. Parameter:out is the return value which is going to be sent back to the client.

func (*Server) Serve

func (s *Server) Serve() error

func (*Server) Tick

func (s *Server) Tick() (delay time.Duration, action gnet.Action)

Tick fires immediately after the server starts and will fire again following the duration specified by the delay return value.

type Session

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

func NewSession

func NewSession(c config.Config) *Session

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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