Package-Level Type Names (total 13, in which 10 are exported)
/* sort exporteds by: | */
AtomicConfig is atomic tg.Config.Valueatomic.ValueValue.vany CompareAndSwap executes the compare-and-swap operation for the [Value].
All calls to CompareAndSwap for a given Value must use values of the same
concrete type. CompareAndSwap of an inconsistent type panics, as does
CompareAndSwap(old, nil). Load loads atomically config and returns it. Store saves given config atomically. Swap stores new into Value and returns the previous value. It returns nil if
the Value is empty.
All calls to Swap for a given Value must use values of the same concrete
type. Swap of an inconsistent type panics, as does Swap(nil).
func NewAtomicConfig(cfg tg.Config) *AtomicConfig
Conn is a Telegram client connection. InitConnection parameters. // immutable cdnNeedsInit mirrors TDesktop connectionInited state for CDN transport.
true means requests must go via invokeWithLayer(initConnection). State fields. Wrappers for external world, like logs or PRNG.
Should be immutable. // immutable // immutable // immutable // immutable // immutable // immutable Handler passed by client. // immutablelatesttime.Time layer is the schema layer sent in invokeWithLayer. // immutable // immutable Connection parameters. // immutablemuxsync.Mutex needsInit is set when the server answered CONNECTION_NOT_INITED or
CONNECTION_LAYER_INVALID on a regular (non-CDN) connection: it dropped
the connection state of the session, e.g. after the account logged in
on another device. Requests then go via
invokeWithLayer(initConnection) until one succeeds, as in Telegram
Desktop (Session::setConnectionNotInited) and TDLib
(AuthData::on_connection_not_inited). onDead is called on connection death.ongoingint pending buffers OnSession events until initConnection config is available. MTProto connection. // immutable // immutable setup is callback which called after initConnection, but before ready signaling.
This is necessary to transfer auth from previous connection to another DC. // nilable Invoke implements Invoker. OnMessage implements mtproto.Handler. OnNewSession implements mtproto.NewSessionHandler. OnSession implements mtproto.Handler. Ping calls ping for underlying protocol connection. Ready returns channel to determine connection readiness.
Useful for pooling. Run initialize connection.(*Conn) cdnInitRequest(query bin.Object) bin.Object(*Conn) configReady() bool(*Conn) flushPendingSession() error(*Conn) init(ctx context.Context) error initRequest wraps query in initConnection with the device parameters.(*Conn) invokeCDN(ctx context.Context, input bin.Encoder, output bin.Decoder) error(*Conn) invokeCDNRaw(ctx context.Context, input bin.Encoder, output bin.Decoder) error(*Conn) invokeCDNWrapped(ctx context.Context, input bin.Encoder, output bin.Decoder) error invokeRaw sends the request with the same wrapping as Invoke, but does not
wait for connection readiness. invokeReinit sends the request wrapped in initConnection and clears
needsInit when the server accepts it.(*Conn) trackInvoke() func()(*Conn) waitSession(ctx context.Context) error(*Conn) wrapRequest(req bin.Object) bin.Object
*Conn : NewSessionHandler
*Conn : github.com/gotd/td/mtproto.Handler
*Conn : github.com/gotd/td/mtproto.NewSessionHandler
*Conn : github.com/gotd/td/pool.Conn
*Conn : github.com/gotd/td/tg.Invoker
*Conn : github.com/gotd/td/telegram.clientConn
func CreateConn(create mtproto.Dialer, mode ConnMode, appID int, opts mtproto.Options, connOpts ConnOptions) *Conn
DeviceConfig is config which send when Telegram connection session created. Application version. Device model. Code for the language used on the client, ISO 639-1 standard. Language pack to use. Additional initConnection parameters. For now, only the tz_offset field is supported,
for specifying timezone offset in seconds. Info about an MTProto proxy. Code for the language used on the device's OS, ISO 639-1 standard. Operating system version. SetDefaults sets default values.
InitError is returned by Conn.Run when the initConnection request
(invokeWithLayer(initConnection(help.getConfig))) fails.
It lets callers tell a rejected connection setup apart from errors of
the transport, the key exchange or the setup callback.Errerror Error implements error. Unwrap returns the underlying error.
*InitError : github.com/go-faster/errors.Wrapper
*InitError : error
NewSessionHandler is implemented by a Handler that wants to know when the
server created a new session (new_session_created).( NewSessionHandler) OnNewSession(firstMsgID int64) error
*Conn
github.com/gotd/td/mtproto.NewSessionHandler(interface)
github.com/gotd/td/telegram.primaryHandler
NewSessionHandler : github.com/gotd/td/mtproto.NewSessionHandler
NoopHandler is a noop handler. OnMessage implements Handler OnSession implements Handler.
NoopHandler : Handler
SetupCallback is an optional setup connection callback.
It is called after initConnection, but before the connection is ready.
The invoker sends requests directly through the connection without
waiting for readiness; it must not be used after the callback returns.
setupInvoker is the tg.Invoker passed to SetupCallback.
Setup runs inside init, before the connection is signaled as ready, so it
must not go through Invoke: waitSession would wait for init itself and the
connection would deadlock. Like tdlib (auth.importAuthorization is sent with
AuthFlag::Off), setup requests bypass the readiness gate.conn*Conn Invoke implements tg.Invoker.
setupInvoker : github.com/gotd/td/tg.Invoker
Package-Level Functions (total 4, in which 2 are exported)
isNotInited reports whether err tells that the server has no
initConnection state for the session, so the request must be re-sent
wrapped in invokeWithLayer(initConnection).
Package-Level Variables (only one, which is unexported)
The pages are generated with Goldsv0.8.7. (GOOS=linux GOARCH=amd64)
Golds is a Go 101 project developed by Tapir Liu.
PR and bug reports are welcome and can be submitted to the issue list.
Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds.