Voice region switch procedure
- Client changes voice region via settings;
- Http api touches DB;
- DB:
- updates
channeltable – this makes all related voice states immediately have newvoice_region; - fires VoiceRegionChange event, only if voice region is actually changed
(corner case: old/new region might be
null(automatic), which means actual voice region must be derived first)
- updates
- Voice IPC catches event:
- if we’re serving old region: drop states;
- if we’re serving new region: insert states;
- Gateway catches event and sends VOICE_SERVER_UPDATE w/ the same channel/guild/token and new endpoint;
Automatic voice region assignment
voice_region = null means “auto-assign voice region”
Current approach:
- Calc hash of voice channel id;
- Get region index by
index = hash % voice_regions.len() - Get region name by
voice_regions[index].name()