Skip to content

Commit 29987f7

Browse files
authored
Update example code in README.md to version 0.9.1 (#17)
1 parent d1624a9 commit 29987f7

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,17 @@ let params = "hello" // any Encodable
3535
let response: Decodable = try await session.sendRequest(params, method: "my_method")
3636

3737
Task {
38-
for await (request, handler, data) in session.requestSequence {
39-
// inspect request, possibly re-decode with more specific type,
40-
// and reply using the handler
41-
}
42-
}
43-
44-
Task {
45-
for await (notification, data) in session.notificationSequence {
46-
// inspect notification
38+
for await event in await session.eventSequence {
39+
switch event {
40+
case .request(let request, let handler, let data):
41+
// inspect request, possibly re-decode with more specific type,
42+
// and reply using the handler
43+
44+
case .notification(let notification, let data):
45+
// inspect notification
46+
case .error(let error):
47+
print("Error: \(error)")
48+
}
4749
}
4850
}
4951
```

0 commit comments

Comments
 (0)