Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hub.on is not getting called after establishing connection #117

Open
AnandPGautam opened this issue Jul 5, 2018 · 1 comment
Open

Hub.on is not getting called after establishing connection #117

AnandPGautam opened this issue Jul 5, 2018 · 1 comment

Comments

@AnandPGautam
Copy link

I am using SwiftR V2_2_0 with XCode 9.4.1. The problem is Hub.invoke method is getting called but in other device Hub.on method is not getting called. I have checked for the connection and Connection State is showing as Connected, And also I can able to log Connection ID for both the devices.

I tried to log the error, but it was not showing in console.

I am using CocoaPods to install this using -> pod 'SwiftR'

Please advise me.

@Pankaj03
Copy link

Pankaj03 commented Oct 27, 2018

@AnandPGautam @adamhartford Please help. I am also facing the same issue. Please check my implementation as:

`
func setUpSignalR() {

    connection = SignalR(kConnection)
    connection.useWKWebView = false
    chatHub = Hub(kHub)
    connection.addHub(chatHub)
    
    chatHub.on(kRoom) { [weak self] args in
        print("ARGS : ",args as Any)
    }
    
    // SignalR events
    
    connection.starting = { [weak self] in
    }        
   // connection.
    connection.reconnecting = { [weak self] in
    }
    
    connection.connected = { [weak self] in
        print("Connection ID: \(self!.connection.connectionID!)")
    }
    
    connection.reconnected = { [weak self] in
}
    
    connection.disconnected = { [weak self] in
    }        
    connection.connectionSlow = { print("Connection slow...") }
    
    connection.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?.connection.start()
        }
    }   
    connection.start()
}

`

And for sending messages:

do { try chatHub.invoke(kRoom, arguments:[UserName!,text]) } catch { print(error) }

Please guide, where I am wrong. I am able to send messages, but not receiving.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants