feat: early definition of ready event with voice state
Signed-off-by: Infi <infi@infi.sh>
This commit is contained in:
parent
12b08edaf0
commit
fd8d22b170
|
|
@ -41,9 +41,10 @@ enum class PermissionBit(val value: Long) {
|
||||||
MuteMembers(1L shl 33),
|
MuteMembers(1L shl 33),
|
||||||
DeafenMembers(1L shl 34),
|
DeafenMembers(1L shl 34),
|
||||||
MoveMembers(1L shl 35),
|
MoveMembers(1L shl 35),
|
||||||
|
Listen(1L shl 36),
|
||||||
|
|
||||||
// * Misc. permissions
|
// * Misc. permissions
|
||||||
// % Bits 36 to 52: free area
|
// % Bits 37 to 52: free area
|
||||||
// % Bits 53 to 64: do not use
|
// % Bits 53 to 64: do not use
|
||||||
|
|
||||||
// * Grant all permissions
|
// * Grant all permissions
|
||||||
|
|
@ -85,7 +86,8 @@ object BitDefaults {
|
||||||
PermissionBit.SendEmbeds +
|
PermissionBit.SendEmbeds +
|
||||||
PermissionBit.UploadFiles +
|
PermissionBit.UploadFiles +
|
||||||
PermissionBit.Connect +
|
PermissionBit.Connect +
|
||||||
PermissionBit.Speak
|
PermissionBit.Speak +
|
||||||
|
PermissionBit.Listen
|
||||||
|
|
||||||
val SavedMessages =
|
val SavedMessages =
|
||||||
PermissionBit.GrantAllSafe.value
|
PermissionBit.GrantAllSafe.value
|
||||||
|
|
|
||||||
|
|
@ -50,6 +50,7 @@ import io.ktor.websocket.readText
|
||||||
import io.ktor.websocket.send
|
import io.ktor.websocket.send
|
||||||
import kotlinx.coroutines.channels.consumeEach
|
import kotlinx.coroutines.channels.consumeEach
|
||||||
import kotlinx.serialization.SerializationException
|
import kotlinx.serialization.SerializationException
|
||||||
|
import logcat.logcat
|
||||||
|
|
||||||
enum class DisconnectionState {
|
enum class DisconnectionState {
|
||||||
Disconnected,
|
Disconnected,
|
||||||
|
|
@ -146,10 +147,14 @@ object RealtimeSocket {
|
||||||
|
|
||||||
"Ready" -> {
|
"Ready" -> {
|
||||||
val readyFrame = RevoltJson.decodeFromString(ReadyFrame.serializer(), rawFrame)
|
val readyFrame = RevoltJson.decodeFromString(ReadyFrame.serializer(), rawFrame)
|
||||||
Log.d(
|
|
||||||
"RealtimeSocket",
|
logcat {
|
||||||
"Received ready frame with ${readyFrame.users.size} users, ${readyFrame.servers.size} servers, ${readyFrame.channels.size} channels, and ${readyFrame.emojis.size} emojis."
|
"Received ready frame with ${readyFrame.users.size} users, " +
|
||||||
)
|
"${readyFrame.servers.size} servers, " +
|
||||||
|
"${readyFrame.channels.size} channels, " +
|
||||||
|
"${readyFrame.emojis.size} emojis, " +
|
||||||
|
"and ${readyFrame.voiceStates.size} voice states."
|
||||||
|
}
|
||||||
|
|
||||||
Log.d("RealtimeSocket", "Adding users to cache.")
|
Log.d("RealtimeSocket", "Adding users to cache.")
|
||||||
val userMap = readyFrame.users.associateBy { it.id!! }
|
val userMap = readyFrame.users.associateBy { it.id!! }
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
package chat.revolt.api.realtime.frames.receivable
|
package chat.revolt.api.realtime.frames.receivable
|
||||||
|
|
||||||
import chat.revolt.api.schemas.Channel
|
import chat.revolt.api.schemas.Channel
|
||||||
|
import chat.revolt.api.schemas.ChannelVoiceState
|
||||||
import chat.revolt.api.schemas.Embed
|
import chat.revolt.api.schemas.Embed
|
||||||
import chat.revolt.api.schemas.Emoji
|
import chat.revolt.api.schemas.Emoji
|
||||||
import chat.revolt.api.schemas.Member
|
import chat.revolt.api.schemas.Member
|
||||||
|
|
@ -42,7 +43,8 @@ data class ReadyFrame(
|
||||||
val users: List<User>,
|
val users: List<User>,
|
||||||
val servers: List<Server>,
|
val servers: List<Server>,
|
||||||
val channels: List<Channel>,
|
val channels: List<Channel>,
|
||||||
val emojis: List<Emoji>
|
val emojis: List<Emoji>,
|
||||||
|
@SerialName("voice_states") val voiceStates: List<ChannelVoiceState>,
|
||||||
)
|
)
|
||||||
|
|
||||||
typealias MessageFrame = Message
|
typealias MessageFrame = Message
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
package chat.revolt.api.schemas
|
||||||
|
|
||||||
|
import kotlinx.serialization.SerialName
|
||||||
|
import kotlinx.serialization.Serializable
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class ChannelVoiceState(
|
||||||
|
val id: String,
|
||||||
|
val participants: List<UserVoiceState>,
|
||||||
|
val node: String,
|
||||||
|
)
|
||||||
|
|
||||||
|
@Serializable
|
||||||
|
data class UserVoiceState(
|
||||||
|
val id: String,
|
||||||
|
@SerialName("is_receiving") val isReceiving: Boolean,
|
||||||
|
@SerialName("is_publishing") val isPublishing: Boolean,
|
||||||
|
val screensharing: Boolean,
|
||||||
|
val camera: Boolean,
|
||||||
|
)
|
||||||
Loading…
Reference in New Issue