You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: aspnetcore/signalr/swift-client.md
+2-14Lines changed: 2 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -60,18 +60,6 @@ let connection = HubConnectionBuilder()
60
60
tryawait connection.start()
61
61
```
62
62
63
-
### Cross-origin connections (CORS)
64
-
65
-
Typically, browsers load connections from the same domain as the requested page. However, there are occasions when a connection to another domain is required.
66
-
67
-
When making [cross domain requests](xref:signalr/security#cross-origin-resource-sharing), the client code ***must*** use an absolute URL instead of a relative URL. For cross domain requests, change `.withUrl(url: "/chathub")` to `.withUrl(url: "https://{App domain name}/chathub")`.
68
-
69
-
To prevent a malicious site from reading sensitive data from another site, [cross-origin connections](xref:security/cors) are disabled by default. To allow a cross-origin request, enable [CORS](xref:security/cors):
<xref:Microsoft.AspNetCore.Builder.CorsMiddlewareExtensions.UseCors%2A> must be called before calling <xref:Microsoft.AspNetCore.Builder.HubEndpointRouteBuilderExtensions.MapHub%2A>.
74
-
75
63
## Call client methods from the hub
76
64
77
65
To receive messages from the server, register a handler using the `on` method. The on method takes the name of the hub method and a closure that will be executed when the server calls that method.
@@ -149,8 +137,8 @@ public class ChatHub : Hub
149
137
To receive a stream of data from the server, use the `stream` method. The method returns a stream that you can iterate over asynchronously:
150
138
151
139
```swift
152
-
letstream: any StreamResult<String> =tryawait connection.stream(method: "StreamMethod")
153
-
fortryawait item instream.stream {
140
+
letstreamResult: any StreamResult<String> =tryawait connection.stream(method: "StreamMethod")
0 commit comments