Skip to content

Commit 0308d42

Browse files
docs: Readme updates
1 parent a913808 commit 0308d42

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ To use this package, include it in your `Package.swift` dependencies:
2020
.package(url: "https://github.com/GraphQLSwift/GraphQLTransportWS", from: "<version>")
2121
```
2222

23-
Then create a class to implement the `Messenger` protocol. Here's an example using
23+
Then create a concrete type that conforms to the `Messenger` protocol. Here's an example using
2424
[`WebSocketKit`](https://github.com/vapor/websocket-kit):
2525

2626
```swift
@@ -31,12 +31,12 @@ import GraphQLTransportWS
3131
struct WebSocketMessenger: Messenger {
3232
let websocket: WebSocket
3333

34-
func send<S>(_ message: S) where S: Collection, S.Element == Character async throws {
35-
try await websocket.send(message)
34+
func send(_ message: Data) async throws {
35+
try await websocket.send(String(decoding: message, as: UTF8.self))
3636
}
3737

3838
func error(_ message: String, code: Int) async throws {
39-
try await websocket.send("\(code): \(message)")
39+
try await websocket.close(code: code)
4040
}
4141

4242
func close() async throws {
@@ -73,9 +73,9 @@ routes.webSocket(
7373
)
7474
}
7575
)
76-
let incoming = AsyncStream<String> { continuation in
76+
let incoming = AsyncStream<Data> { continuation in
7777
websocket.onText { _, message in
78-
continuation.yield(message)
78+
continuation.yield(Data(message.utf8))
7979
}
8080
}
8181
try await server.listen(to: incoming)

0 commit comments

Comments
 (0)