From 73df78db9ef8ba7574930d010b8ff012e66bd7ce Mon Sep 17 00:00:00 2001 From: EriaWist <49594697+EriaWist@users.noreply.github.com> Date: Thu, 8 May 2025 21:36:23 +0800 Subject: [PATCH] Update example code in README.md to version 0.9.1 --- README.md | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 357ce13..6deb143 100644 --- a/README.md +++ b/README.md @@ -35,15 +35,17 @@ let params = "hello" // any Encodable let response: Decodable = try await session.sendRequest(params, method: "my_method") Task { - for await (request, handler, data) in session.requestSequence { - // inspect request, possibly re-decode with more specific type, - // and reply using the handler - } -} - -Task { - for await (notification, data) in session.notificationSequence { - // inspect notification + for await event in await session.eventSequence { + switch event { + case .request(let request, let handler, let data): + // inspect request, possibly re-decode with more specific type, + // and reply using the handler + + case .notification(let notification, let data): + // inspect notification + case .error(let error): + print("Error: \(error)") + } } } ```