[feat] add MCP file browsing and cancellable transfers

This commit is contained in:
dijunkun
2026-11-06 20:36:48 +08:00
parent 0aed57ed4d
commit 6bfcd5cf3d
20 changed files with 537 additions and 23 deletions
@@ -204,6 +204,16 @@ class Session {
if (send_) send_(kFileStream, packet.data(), packet.size());
return true;
}
void CancelReceive(uint32_t id) {
uint64_t total = 0;
{
std::lock_guard lock(mutex_);
const auto found = incoming_.find(id);
if (found != incoming_.end()) total = found->second.total;
}
const auto packet = EncodeFileCancel(id, total);
Receive(packet.data(), packet.size());
}
// A cancelled connection cannot be restarted by a late data callback.
void Cancel() {
std::lock_guard<std::mutex> lock(mutex_);