Muh*_*ain 4 signalr swift .net-core asp.net-core
我在.NET CORE 2.1.403上开发了一个 WebApi 后端项目,所有的 webapi 路由都运行良好。现在我需要对用 Swift 开发的 iOS 应用程序进行实时更新。
我找不到任何支持 SignalR 的官方库。搜索后我发现https://github.com/moozzyk/SignalR-Client-Swift支持.NET CORE
但没有我们可以依赖的详细文档。但是,我的 Javascript 客户端在.NET CORE 上运行良好。
我以前曾将SwiftR与.NET FRAMEWORK 4.7.1
SignalR 一起使用,并且效果很好。
小智 5
我意识到这是一个迟到的回复,但对于它的价值,我已经成功地在 iOS 中使用了https://github.com/moozzyk/SignalR-Client-Swift SignalR 客户端,反对 AspNet Core 服务器实现。GitHub 上的文档有点少,但是使用起来非常简单。例如:
// Set up a connection to the SignalR hub on the servver.
private func connectToSignalRHub() {
// Are we already connected to the hub?
if !isHubConnected {
let url = URL(string: "http://\(hostName):\(serverPort)/hub")!
hubConnection = HubConnectionBuilder(url: url).withLogging(minLogLevel: .error).build()
if let hub = hubConnection {
hub.delegate = self
// Set our callbacks for the messages we expect from the SignalR hub.
hub.on(method: "ProgressUpdate", callback: {
args, typeConverter in
if let data = try? typeConverter.convertFromWireType(obj: args[0], targetType: String.self) {
self.onHubProgressUpdate(progress: data)
}
})
// Start the hub connection.
hub.start()
}
}
}
Run Code Online (Sandbox Code Playgroud)
如果您仍然需要它,我很乐意分享更多细节。
归档时间: |
|
查看次数: |
1619 次 |
最近记录: |