Documentation ¶
Index ¶
- Constants
- Variables
- func NewAuthSessionManager() *authSessionManager
- type Logger
- type Server
- func (s *Server) Close()
- func (s *Server) GatewaySendDataToGateway(ctx context.Context, in *gateway.TLGatewaySendDataToGateway) (reply *mtproto.Bool, err error)
- func (s *Server) GetAuthKey(authKeyId int64) *mtproto.AuthKeyInfo
- func (s *Server) GetConnCounts() int
- func (s *Server) OnClosed(c gnet.Conn, err error) (action gnet.Action)
- func (s *Server) OnInitComplete(svr gnet.Server) (action gnet.Action)
- func (s *Server) OnOpened(c gnet.Conn) (out []byte, action gnet.Action)
- func (s *Server) OnShutdown(svr gnet.Server)
- func (s *Server) Ping(ctx context.Context) (err error)
- func (s *Server) PreWrite(c gnet.Conn)
- func (s *Server) PutAuthKey(keyInfo *mtproto.AuthKeyInfo)
- func (s *Server) React(frame interface{}, c gnet.Conn) (out interface{}, action gnet.Action)
- func (s *Server) Serve() error
- func (s *Server) Tick() (delay time.Duration, action gnet.Action)
- type Session
Constants ¶
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 )
const ( RES_STATE_NONE = 0x00 RES_STATE_OK = 0x01 RES_STATE_ERROR = 0x02 )
const (
SHA_DIGEST_LENGTH = 20
)
Variables ¶
var (
ErrSessionNotFound = errors.New("not found session")
)
Functions ¶
func NewAuthSessionManager ¶
func NewAuthSessionManager() *authSessionManager
Types ¶
type Server ¶
type Server struct { *gnet.EventServer // contains filtered or unexported fields }
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 (*Server) OnClosed ¶
OnClosed fires when a connection has been closed. The parameter:err is the last known connection error.
func (*Server) OnInitComplete ¶
OnInitComplete fires when the server is ready for accepting connections. The parameter:server has information and various utilities.
func (*Server) OnOpened ¶
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 ¶
OnShutdown fires when the server is being shut down, it is called right after all event-loops and connections are closed.
func (*Server) PreWrite ¶
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)