示例#1
0
 public void Dispose()
 {
     Disconnect();
     _voiceChannelService?.Dispose();
     _client.Dispose();
     _client              = null;
     _bufferBytes         = null;
     _voiceChannelService = null;
     _token       = null;
     _voiceBuffer = null;
 }
示例#2
0
 public ConnectionHandler(PluginUserCredential token)
 {
     _client = new DiscordSocketClient(new DiscordSocketConfig
     {
         LogLevel = LogSeverity.Debug
     });
     _token = Encoding.Default.GetString(token.GetStoredData());
     _voiceChannelService = new VoiceChannelService(_client);
     _voiceChannelService.VoiceConnected    += _audioService_VoiceConnected;
     _voiceChannelService.VoiceDisconnected += _audioService_VoiceDisconnected;
     _client.Log += Client_Log;
     _client.UserVoiceStateUpdated += _client_UserVoiceStateUpdated;
     _client.Ready        += _client_Ready;
     _client.Connected    += _client_Connected;
     _client.Disconnected += _client_Disconnected;
     _client.LoggedOut    += _client_LoggedOut;
     Logging.Log("ConnectionHandler loaded");
 }