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

Subscribing without waiting for connection doesn't attach #218

Closed
tcard opened this issue Feb 15, 2016 · 1 comment
Closed

Subscribing without waiting for connection doesn't attach #218

tcard opened this issue Feb 15, 2016 · 1 comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.

Comments

@tcard
Copy link
Contributor

tcard commented Feb 15, 2016

I am toying around with the library in a real iOS app. If you create a channel just after creating the realtime instance, it never attaches.

This doesn't work, and the channel seems stuck in the ATTACHING state:

let client = ARTRealtime(key: "I2E_JQ.j3RKrw:oh3rkv_jaIB3S60u")
let channel = client.channels.get("government")
channel.on { errorInfo in
    print("channel state \(channel.state.rawValue) \(errorInfo)")
}
channel.subscribe { message in
    print(message)
}

This does work:

let client = ARTRealtime(key: "I2E_JQ.j3RKrw:oh3rkv_jaIB3S60u")
client.connection.on { stateChange in
    print("connection state \(stateChange?.current.rawValue)")
    guard let current = stateChange?.current else { return }
    if current == .Connected {
        print("connected!")
        let channel = client.channels.get("government")
        channel.on { errorInfo in
            print("channel state \(channel.state.rawValue) \(errorInfo)")
        }
        channel.subscribe { message in
            print(message)
        }
    }
}
@tcard tcard added the bug Something isn't working. It's clear that this does need to be fixed. label Feb 15, 2016
@tcard
Copy link
Contributor Author

tcard commented Feb 19, 2016

I can't reproduce this. No idea why it wasn't working...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working. It's clear that this does need to be fixed.
Development

No branches or pull requests

1 participant