Skip to main content

Module sender_task

Module sender_task 

Source
Expand description

The sender task: a single tokio::spawn-ed loop that owns MtpSender and is the only entity that touches the TCP socket.

External callers interact via two channels:

  • RpcEnqueue: send a pre-serialised TL body + oneshot::Sender to the task. The task enqueues it into MtpSender, and the oneshot is fulfilled when the server responds. This replaces the old do_rpc_call + Mutex<ConnectionWriter>

    • pending HashMap pattern.
  • ReconnectRequest: send a new (TcpStream, EncryptedSession, FrameKind, Option<perm_key>) to the task after a reconnect completes. The task calls MtpSender::set_stream and resumes the loop.

The task forwards raw update bodies (everything MtpSender::step() returns that is not an rpc_result) via FrameEvent to the client’s dispatch path.

Structs§

ReconnectRequest
Reconnect request: replace the TCP stream inside the sender task.
RpcEnqueue
A single RPC request sent from any caller to the sender task.
SenderHandle
Sender-side handles given to the client after spawning the sender task.

Enums§

FrameEvent
Events the sender task sends back to the client.

Functions§

spawn_sender_task
Spawn the sender task. Returns a SenderHandle for the client and an mpsc::Receiver<FrameEvent> for receiving update bodies and errors.