Skip to content

Commit aa756b4

Browse files
authored
Some more updates
1 parent b825fc9 commit aa756b4

File tree

2 files changed

+46
-19
lines changed

2 files changed

+46
-19
lines changed

aspnetcore/signalr/client-features.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,18 +29,18 @@ The 1.x versions of SignalR map to the 2.1 and 2.2 .NET Core releases and have t
2929

3030
The table below shows the features and support for the clients that offer real-time support. For each feature, the *minimum* version supporting this feature is listed. If no version is listed, the feature isn't supported.
3131

32-
| Feature | Server | .NET client | JavaScript client | Java client |
33-
| ---- | :-: | :-: | :-: | :-: |
34-
| Azure SignalR Service Support |2.1.0|1.0.0|1.0.0|1.0.0|
35-
| [Server-to-client Streaming](xref:signalr/streaming) |2.1.0|1.0.0|1.0.0|1.0.0|
36-
| [Client-to-server Streaming](xref:signalr/streaming) |3.0.0|3.0.0|3.0.0|3.0.0|
37-
| Automatic Reconnection ([.NET](xref:signalr/dotnet-client#handle-lost-connection), [JavaScript](xref:signalr/javascript-client#reconnect-clients)) |3.0.0|3.0.0|3.0.0||
38-
| WebSockets Transport |2.1.0|1.0.0|1.0.0|1.0.0|
39-
| Server-Sent Events Transport |2.1.0|1.0.0|1.0.0||
40-
| Long Polling Transport |2.1.0|1.0.0|1.0.0|3.0.0|
41-
| JSON Hub Protocol |2.1.0|1.0.0|1.0.0|1.0.0|
42-
| MessagePack Hub Protocol |2.1.0|1.0.0|1.0.0|5.0.0|
43-
| Client Results |7.0.0|7.0.0|7.0.0|7.0.0|
32+
| Feature | Server | .NET client | JavaScript client | Java client | Swift client |
33+
| ---- | :-: | :-: | :-: | :-: | :-: |
34+
| Azure SignalR Service Support |2.1.0|1.0.0|1.0.0|1.0.0|1.0.0-preview.1|
35+
| [Server-to-client Streaming](xref:signalr/streaming) |2.1.0|1.0.0|1.0.0|1.0.0|1.0.0-preview.1|
36+
| [Client-to-server Streaming](xref:signalr/streaming) |3.0.0|3.0.0|3.0.0|3.0.0||
37+
| Automatic Reconnection ([.NET](xref:signalr/dotnet-client#handle-lost-connection), [JavaScript](xref:signalr/javascript-client#reconnect-clients)) |3.0.0|3.0.0|3.0.0||1.0.0-preview.1|
38+
| WebSockets Transport |2.1.0|1.0.0|1.0.0|1.0.0|1.0.0-preview.1|
39+
| Server-Sent Events Transport |2.1.0|1.0.0|1.0.0||1.0.0-preview.1|
40+
| Long Polling Transport |2.1.0|1.0.0|1.0.0|3.0.0|1.0.0-preview.1|
41+
| JSON Hub Protocol |2.1.0|1.0.0|1.0.0|1.0.0|1.0.0-preview.1|
42+
| MessagePack Hub Protocol |2.1.0|1.0.0|1.0.0|5.0.0|1.0.0-preview.1|
43+
| Client Results |7.0.0|7.0.0|7.0.0|7.0.0|1.0.0-preview.1|
4444

4545
Support for enabling additional client features is tracked in [our issue tracker](https://github.com/dotnet/AspNetCore/issues).
4646

aspnetcore/signalr/swift-client.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,10 @@ import PackageDescription
3232
let package = Package(
3333
name: "signalr-client-app",
3434
dependencies: [
35-
.package(url: "https://github.com/Azure/signalr-swift")
35+
.package(url: "https://github.com/dotnet/signalr-client-swift", branch: "main")
3636
],
3737
targets: [
38-
.target(
39-
name: "YourTargetName",
40-
dependencies: [
41-
.product(name: "SignalRClient", package: "signalr-swift")
42-
]
43-
)
38+
.executableTarget(name: "YourTargetName", dependencies: [.product(name: "SignalRClient", package: "signalr-client-swift")])
4439
]
4540
)
4641
```
@@ -175,6 +170,22 @@ let connection = HubConnectionBuilder()
175170

176171
Without parameters, withAutomaticReconnect() configures the client to wait 0, 2, 10, and 30 seconds respectively before each reconnect attempt. After four failed attempts, the client stops trying to reconnect.
177172

173+
Before starting any reconnect attempts, the `HubConnection` transitions to the `Reconnecting` state and fires its `onReconnecting` callbacks.
174+
175+
After the reconnection succeeds, the `HubConnection` transitions to the `connected` state and fires its `onReconnected` callbacks.
176+
177+
A general way to use `onReconnecting` and `onReconnected` is to mark the connection state changes:
178+
179+
```swift
180+
connection.onReconnecting { error in
181+
// connection is disconnected because of error
182+
}
183+
184+
connection.onReconnected {
185+
// connection is connected back
186+
}
187+
```
188+
178189
### Configure strategy in automatic reconnect
179190

180191
To customize the reconnect behavior, you can pass an array of numbers representing the delay in seconds before each reconnect attempt. For more granular control, pass an object that conforms to the RetryPolicy protocol.
@@ -216,6 +227,22 @@ You can customize the client's timeout and keep-alive settings via the HubConnec
216227
|withKeepAliveInterval| 15 (seconds)|Determines the interval at which the client sends ping messages and is set directly on HubConnectionBuilder. This setting allows the server to detect hard disconnects, such as when a client unplugs their computer from the network. Sending any message from the client resets the timer to the start of the interval. If the client hasn't sent a message in the ClientTimeoutInterval set on the server, the server considers the client disconnected.|
217228
|withServerTimeout| 30 (seconds)|Determines the interval at which the client waits for a response from the server before it considers the server disconnected. This setting is set directly on HubConnectionBuilder.|
218229

230+
## Configure transport
231+
232+
The SignalR Swift client supports three transports: LongPolling, ServerSentEvents, and WebSockets. By default, the client will use WebSockets if the server supports it, and fall back to ServerSentEvents and LongPolling if it doesn't. You can configure the client to use a specific transport by calling `withUrl(url:transport:)` while building the connection.
233+
234+
```swift
235+
let connection = HubConnectionBuilder()
236+
.withUrl(url: "https://your-signalr-server", transport: .webSockets) // use websocket only
237+
.build()
238+
```
239+
240+
```swift
241+
let connection = HubConnectionBuilder()
242+
.withUrl(url: "https://your-signalr-server", transport: [.webSockets, .serverSentEvents]) // use websockets and server sent events
243+
.build()
244+
```
245+
219246
## Additional resources
220247

221248
* [WebPack and TypeScript tutorial](xref:tutorials/signalr-typescript-webpack)

0 commit comments

Comments
 (0)