Documentation
¶
Overview ¶
Package mtproto implements MTProto connection.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Conn ¶
type Conn struct {
// contains filtered or unexported fields
}
Conn represents a MTProto client to Telegram.
func (*Conn) InvokeRaw ¶
InvokeRaw sens input and decodes result into output.
NOTE: Assuming that call contains content message (seqno increment).
type Error ¶
type Error struct {
Code int // 420
Message string // FLOOD_WAIT_3
Type string // FLOOD_WAIT
Argument int // 3
}
Error represents RPC error returned to request.
func (*Error) ExtractArgument ¶
func (e *Error) ExtractArgument()
ExtractArgument extracts Type and Argument from Message.
type MessageIDSource ¶
type MessageIDSource interface {
New(t proto.MessageType) int64
}
MessageIDSource is message id generator.
type Options ¶
type Options struct {
// PublicKeys of telegram.
//
// If not provided, embedded public keys will be used.
PublicKeys []*rsa.PublicKey
// Transport to use. Default dialer will be used if not provided.
Transport Transport
// Network to use. Defaults to tcp.
Network string
// Random is random source. Defaults to crypto.
Random io.Reader
// Logger is instance of zap.Logger. No logs by default.
Logger *zap.Logger
// Handler will be called on received message.
Handler Handler
// AckBatchSize is maximum ack-s to buffer.
AckBatchSize int
// AckInterval is maximum time to buffer ack.
AckInterval time.Duration
// RetryInterval is duration between retries.
RetryInterval time.Duration
// MaxRetries is max retry count until rpc request failure.
MaxRetries int
// MessageID is message id source. Share source between connection to
// reduce collision probability.
MessageID MessageIDSource
// Clock is current time source. Defaults to system time.
Clock clock.Clock
// Types map, used in verbose logging of incoming message.
Types *tmap.Map
// Key that can be used to restore previous connection.
Key crypto.AuthKeyWithID
// Salt from server that can be used to restore previous connection.
Salt int64
// ReadConcurrency limits maximum concurrently handled messages.
// Can be CPU or IO bound depending on message handlers.
// Defaults to GOMAXPROCS if it is not less than 10.
ReadConcurrency int
}
Options of Conn.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.