MadelineProtoDocs/docs/PHPInternal/danog/MadelineProto/DataCenterConnection.md

11 KiB

title: danog\MadelineProto\DataCenterConnection: Datacenter connection. description:

danog\MadelineProto\DataCenterConnection

Back to index

Author: Daniil Gentili daniil@daniil.it

Datacenter connection.

Constants

  • danog\MadelineProto\DataCenterConnection::READ_WEIGHT:

  • danog\MadelineProto\DataCenterConnection::READ_WEIGHT_MEDIA:

  • danog\MadelineProto\DataCenterConnection::WRITE_WEIGHT:

Method list:

  • needReconnect(bool $needsReconnect): void
  • shouldReconnect(): bool
  • getAuthKey(bool $temp): \danog\MadelineProto\MTProto\AuthKey
  • hasAuthKey(bool $temp): bool
  • setAuthKey(\danog\MadelineProto\MTProto\AuthKey|null $key, bool $temp): void
  • getTempAuthKey(): \danog\MadelineProto\MTProto\TempAuthKey
  • getPermAuthKey(): \danog\MadelineProto\MTProto\PermAuthKey
  • hasTempAuthKey(): bool
  • hasPermAuthKey(): bool
  • setTempAuthKey(\danog\MadelineProto\MTProto\TempAuthKey|null $key): void
  • setPermAuthKey(\danog\MadelineProto\MTProto\PermAuthKey|null $key): void
  • bind(bool $pfs): void
  • isBound(): bool
  • isAuthorized(): bool
  • authorized(bool $authorized): void
  • link(string $dc): void
  • resetSession(): void
  • createSession(): void
  • flush(): void
  • getCtx(): \danog\MadelineProto\Stream\ConnectionContext
  • hasCtx(): bool
  • connect(\danog\MadelineProto\Stream\ConnectionContext $ctx, int $id): \Generator
  • signalDisconnect(int $id): void
  • disconnect(): void
  • reconnect(): \Generator
  • restoreBackup(): void
  • getAuthConnection(): \danog\MadelineProto\Connection
  • hasConnection(int $id): bool|int
  • waitGetConnection(): \Generator
  • getConnection(int $id): \danog\MadelineProto\Connection
  • even(): void
  • reading(bool $reading, int $x): void
  • writing(bool $writing, int $x): void
  • setExtra(\danog\MadelineProto\MTProto $API): void
  • getExtra(): \danog\MadelineProto\MTProto
  • isHttp(): bool
  • byIPAddress(): bool
  • isMedia(): bool
  • isCDN(): bool
  • getSettings(): \danog\MadelineProto\Settings\Connection
  • getGenericSettings(): \danog\MadelineProto\Settings
  • jsonSerialize(): array

Methods:

needReconnect(bool $needsReconnect): void

Indicate if this socket needs to be reconnected.

Parameters:

  • $needsReconnect: bool Whether the socket has to be reconnected

Generated by danog/phpdoc

shouldReconnect(): bool

Whether this sockets needs to be reconnected.


Generated by danog/phpdoc

getAuthKey(bool $temp): \danog\MadelineProto\MTProto\AuthKey

Get auth key.

Parameters:

  • $temp: bool Whether to fetch the temporary auth key

See also:


Generated by danog/phpdoc

hasAuthKey(bool $temp): bool

Check if auth key is present.

Parameters:

  • $temp: bool

Generated by danog/phpdoc

setAuthKey(\danog\MadelineProto\MTProto\AuthKey|null $key, bool $temp): void

Set auth key.

Parameters:

  • $key: \danog\MadelineProto\MTProto\AuthKey|null The auth key
  • $temp: bool

See also:


Generated by danog/phpdoc

getTempAuthKey(): \danog\MadelineProto\MTProto\TempAuthKey

Get temporary authorization key.

See also:


Generated by danog/phpdoc

getPermAuthKey(): \danog\MadelineProto\MTProto\PermAuthKey

Get permanent authorization key.

See also:


Generated by danog/phpdoc

hasTempAuthKey(): bool

Check if has temporary authorization key.


Generated by danog/phpdoc

hasPermAuthKey(): bool

Check if has permanent authorization key.


Generated by danog/phpdoc

setTempAuthKey(\danog\MadelineProto\MTProto\TempAuthKey|null $key): void

Set temporary authorization key.

Parameters:

  • $key: \danog\MadelineProto\MTProto\TempAuthKey|null Auth key

See also:


Generated by danog/phpdoc

setPermAuthKey(\danog\MadelineProto\MTProto\PermAuthKey|null $key): void

Set permanent authorization key.

Parameters:

  • $key: \danog\MadelineProto\MTProto\PermAuthKey|null Auth key

See also:


Generated by danog/phpdoc

bind(bool $pfs): void

Bind temporary and permanent auth keys.

Parameters:

  • $pfs: bool Whether to bind using PFS

Generated by danog/phpdoc

isBound(): bool

Check if auth keys are bound.


Generated by danog/phpdoc

isAuthorized(): bool

Check if we are logged in.


Generated by danog/phpdoc

authorized(bool $authorized): void

Set the authorized boolean.

Parameters:

  • $authorized: bool Whether we are authorized

Generated by danog/phpdoc

link(string $dc): void

Link permanent authorization info of main DC to media DC.

Parameters:

  • $dc: string Main DC ID

Generated by danog/phpdoc

resetSession(): void

Reset MTProto sessions.


Generated by danog/phpdoc

createSession(): void

Create MTProto sessions if needed.


Generated by danog/phpdoc

flush(): void

Flush all pending packets.


Generated by danog/phpdoc

getCtx(): \danog\MadelineProto\Stream\ConnectionContext

Get connection context.

See also:


Generated by danog/phpdoc

hasCtx(): bool

Has connection context?


Generated by danog/phpdoc

connect(\danog\MadelineProto\Stream\ConnectionContext $ctx, int $id): \Generator

Connect function.

Parameters:

  • $ctx: \danog\MadelineProto\Stream\ConnectionContext Connection context
  • $id: int Optional connection ID to reconnect

See also:


Generated by danog/phpdoc

signalDisconnect(int $id): void

Signal that a connection ID disconnected.

Parameters:

  • $id: int Connection ID

Generated by danog/phpdoc

disconnect(): void

Close all connections to DC.


Generated by danog/phpdoc

reconnect(): \Generator

Reconnect to DC.

See also:

  • \Generator

Generated by danog/phpdoc

restoreBackup(): void

Restore backed up messages.


Generated by danog/phpdoc

getAuthConnection(): \danog\MadelineProto\Connection

Get connection for authorization.

See also:


Generated by danog/phpdoc

hasConnection(int $id): bool|int

Check if any connection is available.

Parameters:

  • $id: int Connection ID

Generated by danog/phpdoc

waitGetConnection(): \Generator

Get best socket in round robin, asynchronously.

Fully typed return value:

\Generator<int, \Amp\Promise, mixed, \danog\MadelineProto\Connection>

See also:


Generated by danog/phpdoc

getConnection(int $id): \danog\MadelineProto\Connection

Get best socket in round robin.

Parameters:

  • $id: int Connection ID, for manual fetching

See also:


Generated by danog/phpdoc

even(): void

Even out round robin values.


Generated by danog/phpdoc

reading(bool $reading, int $x): void

Indicate that one of the sockets is busy reading.

Parameters:

  • $reading: bool Whether we're busy reading
  • $x: int Connection ID

Generated by danog/phpdoc

writing(bool $writing, int $x): void

Indicate that one of the sockets is busy writing.

Parameters:

  • $writing: bool Whether we're busy writing
  • $x: int Connection ID

Generated by danog/phpdoc

setExtra(\danog\MadelineProto\MTProto $API): void

Set main instance.

Parameters:

  • $API: \danog\MadelineProto\MTProto Main instance

See also:


Generated by danog/phpdoc

getExtra(): \danog\MadelineProto\MTProto

Get main instance.

See also:


Generated by danog/phpdoc

isHttp(): bool

Check if is an HTTP connection.


Generated by danog/phpdoc

byIPAddress(): bool

Check if is connected directly by IP address.


Generated by danog/phpdoc

isMedia(): bool

Check if is a media connection.


Generated by danog/phpdoc

isCDN(): bool

Check if is a CDN connection.


Generated by danog/phpdoc

getSettings(): \danog\MadelineProto\Settings\Connection

Get DC-specific settings.

See also:


Generated by danog/phpdoc

getGenericSettings(): \danog\MadelineProto\Settings

Get global settings.

See also:


Generated by danog/phpdoc

jsonSerialize(): array

JSON serialize function.


Generated by danog/phpdoc


Generated by danog/phpdoc