mirror of
https://github.com/fluxerapp/fluxer
synced 2026-10-18 13:35:42 +09:00
perf(gateway): pre-encode voice state update fanout (#2177)
This commit is contained in:
1 parent
e83a2d6aec
commit
78056e0041
2 files changed
+62
-2
No files matched your search
@@ -111,13 +111,27 @@ maybe_dispatch_voice_state_update(Pids, SanitizedVoiceState, State) ->
|
||||
gateway_dispatch_relay:dispatch_many(
|
||||
[Pid || Pid <- Pids, is_pid(Pid)],
|
||||
voice_state_update,
|
||||
SanitizedVoiceState,
|
||||
dispatch_payload(SanitizedVoiceState),
|
||||
GuildId
|
||||
);
|
||||
undefined ->
|
||||
ok
|
||||
end.
|
||||
|
||||
-spec dispatch_payload(voice_state()) -> voice_state() | {pre_encoded, binary()}.
|
||||
dispatch_payload(SanitizedVoiceState) ->
|
||||
case voice_state_utils:voice_state_guild_id(SanitizedVoiceState) of
|
||||
undefined ->
|
||||
SanitizedVoiceState;
|
||||
_GuildId ->
|
||||
{pre_encoded,
|
||||
iolist_to_binary(
|
||||
json:encode(
|
||||
guild_data_wire:payload(SanitizedVoiceState), fun json:encode_value/2
|
||||
)
|
||||
)}
|
||||
end.
|
||||
|
||||
-spec state_guild_id(guild_state()) -> integer() | undefined.
|
||||
state_guild_id(State) ->
|
||||
case map_utils:get_integer(State, id, undefined) of
|
||||
|
||||
Reference in new issue
Block a user