Skip to content

Commit c2563d4

Browse files
committed
fix: clientId assignment for sandbox test
1 parent 1eae2c0 commit c2563d4

File tree

6 files changed

+9
-7
lines changed

6 files changed

+9
-7
lines changed

chat-android/src/main/java/com/ably/chat/ChatClient.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ internal class DefaultChatClient(
6161
realtimeClient = realtime,
6262
chatApi = chatApi,
6363
clientOptions = clientOptions,
64+
clientId = clientId,
6465
)
6566

6667
override val connection: Connection

chat-android/src/main/java/com/ably/chat/Messages.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ internal class DefaultMessages(
243243

244244
init {
245245
channelStateListener = ChannelStateListener {
246-
if (!it.resumed) updateChannelSerialsAfterDiscontinuity()
246+
if (it.current == ChannelState.attached && !it.resumed) updateChannelSerialsAfterDiscontinuity()
247247
}
248248
channel.on(channelStateListener)
249249
}

chat-android/src/main/java/com/ably/chat/Room.kt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,10 +89,9 @@ internal class DefaultRoom(
8989
override val options: RoomOptions,
9090
val realtimeClient: RealtimeClient,
9191
chatApi: ChatApi,
92+
clientId: String,
9293
) : Room {
9394

94-
private val clientId get() = realtimeClient.auth.clientId
95-
9695
private val _messages = DefaultMessages(
9796
roomId = roomId,
9897
realtimeChannels = realtimeClient.channels,

chat-android/src/main/java/com/ably/chat/Rooms.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ internal class DefaultRooms(
4646
private val realtimeClient: RealtimeClient,
4747
private val chatApi: ChatApi,
4848
override val clientOptions: ClientOptions,
49+
private val clientId: String,
4950
) : Rooms {
5051
private val roomIdToRoom: MutableMap<String, DefaultRoom> = mutableMapOf()
5152

@@ -57,6 +58,7 @@ internal class DefaultRooms(
5758
options = options,
5859
realtimeClient = realtimeClient,
5960
chatApi = chatApi,
61+
clientId = clientId,
6062
)
6163
}
6264

chat-android/src/test/java/com/ably/chat/Sandbox.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,12 @@ class Sandbox private constructor(val appId: String, val apiKey: String) {
3939
}
4040
}
4141

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

47-
internal fun Sandbox.createSandboxRealtime(chatClientId: String = "sandbox-client"): AblyRealtime =
47+
internal fun Sandbox.createSandboxRealtime(chatClientId: String): AblyRealtime =
4848
AblyRealtime(
4949
io.ably.lib.types.ClientOptions().apply {
5050
key = apiKey

chat-android/src/test/java/com/ably/chat/SandboxTest.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class SandboxTest {
2626

2727
@Test
2828
fun `should return yourself as presence member after you entered`() = runTest {
29-
val chatClient = sandbox.createSandboxChatClient()
29+
val chatClient = sandbox.createSandboxChatClient("sandbox-client")
3030
val room = chatClient.rooms.get(UUID.randomUUID().toString())
3131
room.attach()
3232
room.presence.enter()

0 commit comments

Comments
 (0)