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

fix: clientId assignment for sandbox test #57

Merged
merged 1 commit into from
Nov 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions chat-android/src/main/java/com/ably/chat/ChatClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ internal class DefaultChatClient(
realtimeClient = realtime,
chatApi = chatApi,
clientOptions = clientOptions,
clientId = clientId,
)

override val connection: Connection
Expand Down
2 changes: 1 addition & 1 deletion chat-android/src/main/java/com/ably/chat/Messages.kt
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ internal class DefaultMessages(

init {
channelStateListener = ChannelStateListener {
if (!it.resumed) updateChannelSerialsAfterDiscontinuity()
if (it.current == ChannelState.attached && !it.resumed) updateChannelSerialsAfterDiscontinuity()
}
channel.on(channelStateListener)
sacOO7 marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
3 changes: 1 addition & 2 deletions chat-android/src/main/java/com/ably/chat/Room.kt
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,9 @@ internal class DefaultRoom(
override val options: RoomOptions,
val realtimeClient: RealtimeClient,
chatApi: ChatApi,
clientId: String,
) : Room {

private val clientId get() = realtimeClient.auth.clientId

private val _messages = DefaultMessages(
roomId = roomId,
realtimeChannels = realtimeClient.channels,
Expand Down
2 changes: 2 additions & 0 deletions chat-android/src/main/java/com/ably/chat/Rooms.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ internal class DefaultRooms(
private val realtimeClient: RealtimeClient,
private val chatApi: ChatApi,
override val clientOptions: ClientOptions,
private val clientId: String,
) : Rooms {
private val roomIdToRoom: MutableMap<String, DefaultRoom> = mutableMapOf()

Expand All @@ -57,6 +58,7 @@ internal class DefaultRooms(
options = options,
realtimeClient = realtimeClient,
chatApi = chatApi,
clientId = clientId,
)
}

Expand Down
6 changes: 3 additions & 3 deletions chat-android/src/test/java/com/ably/chat/Sandbox.kt
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class Sandbox private constructor(val appId: String, val apiKey: String) {
}
}

internal fun Sandbox.createSandboxChatClient(): DefaultChatClient {
val realtime = createSandboxRealtime(apiKey)
internal fun Sandbox.createSandboxChatClient(chatClientId: String = "sandbox-client"): DefaultChatClient {
val realtime = createSandboxRealtime(chatClientId)
return DefaultChatClient(realtime, ClientOptions())
}

internal fun Sandbox.createSandboxRealtime(chatClientId: String = "sandbox-client"): AblyRealtime =
internal fun Sandbox.createSandboxRealtime(chatClientId: String): AblyRealtime =
AblyRealtime(
io.ably.lib.types.ClientOptions().apply {
key = apiKey
Expand Down
2 changes: 1 addition & 1 deletion chat-android/src/test/java/com/ably/chat/SandboxTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class SandboxTest {

@Test
fun `should return yourself as presence member after you entered`() = runTest {
val chatClient = sandbox.createSandboxChatClient()
val chatClient = sandbox.createSandboxChatClient("sandbox-client")
val room = chatClient.rooms.get(UUID.randomUUID().toString())
room.attach()
room.presence.enter()
Expand Down