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
Hi I'm using SwiftR (0.14.0) in swift 4 Xcode 9 . The following connecting to server but hub.on is not getting called where i need to get response. Please help me to resolve this. Thanks
hubConnection = SignalR("http://chat.friends.com/")
hubConnection.useWKWebView = false
let bearerKey = UserDefaults.standard.string(forKey: "BearerKey")! as NSString
hubConnection?.headers = ["Authorization": "Bearer "+(bearerKey as String)]
simpleHub = Hub("MobileChatHub")
complexHub = Hub("MobileChatHub")
hubConnection.addHub(simpleHub)
hubConnection.addHub(complexHub)
simpleHub.on("ChatContactsResponse") { args in
let message = args![0] as! String
let detail = args![1] as! String
print("Message: \(message)\nDetail: \(detail)\n")
}
complexHub.on("ChatContactsResponse") { args in
let m: AnyObject = args![0] as AnyObject!
print(m)
}
// SignalR events
hubConnection.starting = { [weak self] in
print("Starting...")
}
hubConnection.reconnecting = { [weak self] in
print("Reconnecting...")
}
hubConnection.connected = { [weak self] in
print("Connected. Connection ID: \(String(describing: self!.hubConnection.connectionID))")
do {
try self?.simpleHub.invoke("GetChatContacts", arguments: [false])
} catch {
print(error)
}
}
hubConnection.reconnected = { [weak self] in
print("Reconnected. Connection ID: \(String(describing: self!.hubConnection.connectionID))")
}
hubConnection.disconnected = { [weak self] in
print("Disconnected.")
}
hubConnection.connectionSlow = { print("Connection slow...") }
hubConnection.error = { [weak self] error in
print("Error: \(String(describing: error))")
if let source = error?["source"] as? String , source == "TimeoutException" {
print("Connection timed out. Restarting...")
self?.hubConnection.start()
}
}
hubConnection.start()
The text was updated successfully, but these errors were encountered:
rajeevfp
changed the title
Hub.on never gets called in Swift 4 :(
Hub.on is not getting called in Swift 4 :(
Dec 22, 2017
Can server only send complexHub.on("event") to connectionId register, should you can't catch this event! Before I also faulty this! Fix by use hub.invoke('connect', username);
Hi I'm using SwiftR (0.14.0) in swift 4 Xcode 9 . The following connecting to server but hub.on is not getting called where i need to get response. Please help me to resolve this. Thanks
The text was updated successfully, but these errors were encountered: