Exemple #1
0
        protected override void OnCloseReceived(WebSocketCloseStatus closeStatus, string closeDescription)
        {
            if (closeStatus == WebSocketCloseStatus.NormalClosure)
            {
                return;
            }

            VoiceCloseCode voiceCloseCode = (VoiceCloseCode)closeStatus;

            switch (voiceCloseCode)
            {
            case VoiceCloseCode.Disconnected:
            case VoiceCloseCode.VoiceServerCrashed:
                heartbeatCancellationSource?.Cancel();
                OnResumeRequested?.Invoke(this, EventArgs.Empty);
                break;

            case VoiceCloseCode.InvalidSession:
            case VoiceCloseCode.SessionTimeout:
                heartbeatCancellationSource?.Cancel();
                OnNewSessionRequested?.Invoke(this, EventArgs.Empty);
                break;

            default:
                if ((int)voiceCloseCode >= 4000)
                {
                    log.LogVerbose($"Fatal close code: {voiceCloseCode} ({(int)voiceCloseCode}), {closeDescription}");
                }
                else
                {
                    log.LogVerbose($"Fatal close code: {closeStatus} ({(int)closeStatus}), {closeDescription}");
                }

                OnUnexpectedClose?.Invoke(this, EventArgs.Empty);
                break;
            }
        }
Exemple #2
0
 protected override void OnClosedPrematurely()
 {
     OnUnexpectedClose?.Invoke(this, EventArgs.Empty);
 }