1111
1212namespace NetCord . Gateway . Voice ;
1313
14- public class VoiceClient : WebSocketClient
14+ public partial class VoiceClient : WebSocketClient
1515{
16- public event Func < VoiceReceiveEventArgs , ValueTask > ? VoiceReceive ;
17- public event Func < ValueTask > ? Ready ;
18- public event Func < UserConnectEventArgs , ValueTask > ? UserConnect ;
19- public event Func < UserDisconnectEventArgs , ValueTask > ? UserDisconnect ;
16+ public partial event Func < VoiceReceiveEventArgs , ValueTask > ? VoiceReceive ;
17+ public partial event Func < ValueTask > ? Ready ;
18+ public partial event Func < UserConnectEventArgs , ValueTask > ? UserConnect ;
19+ public partial event Func < UserDisconnectEventArgs , ValueTask > ? UserDisconnect ;
2020
2121 public ulong UserId { get ; }
2222
@@ -192,7 +192,7 @@ void GetIpAndPort(out string ip, out ushort port)
192192 var sessionDescription = payload . Data . GetValueOrDefault ( ) . ToObject ( Serialization . Default . JsonSessionDescription ) ;
193193 _encryption ! . SetKey ( sessionDescription . SecretKey ) ;
194194 InvokeLog ( LogMessage . Info ( "Ready" ) ) ;
195- var readyTask = InvokeEventAsync ( Ready ) ;
195+ var readyTask = InvokeEventAsync ( _ready ) ;
196196
197197 state . IndicateReady ( connectionState ) ;
198198
@@ -237,13 +237,13 @@ void GetIpAndPort(out string ip, out ushort port)
237237 case VoiceOpcode . ClientConnect :
238238 {
239239 var json = payload . Data . GetValueOrDefault ( ) . ToObject ( Serialization . Default . JsonClientConnect ) ;
240- await InvokeEventAsync ( UserConnect , new UserConnectEventArgs ( json . UserIds ) ) . ConfigureAwait ( false ) ;
240+ await InvokeEventAsync ( _userConnect , new UserConnectEventArgs ( json . UserIds ) ) . ConfigureAwait ( false ) ;
241241 }
242242 break ;
243243 case VoiceOpcode . ClientDisconnect :
244244 {
245245 var json = payload . Data . GetValueOrDefault ( ) . ToObject ( Serialization . Default . JsonClientDisconnect ) ;
246- await InvokeEventAsync ( UserDisconnect , new ( json . UserId ) , args =>
246+ await InvokeEventAsync ( _userDisconnect , new ( json . UserId ) , args =>
247247 {
248248 var userId = args . UserId ;
249249 var cache = Cache ;
@@ -259,12 +259,12 @@ void GetIpAndPort(out string ip, out ushort port)
259259 }
260260 }
261261
262- internal ValueTask InvokeVoiceReceiveAsync ( VoiceReceiveEventArgs data ) => InvokeEventAsync ( VoiceReceive , data ) ;
262+ internal ValueTask InvokeVoiceReceiveAsync ( VoiceReceiveEventArgs data ) => InvokeEventAsync ( _voiceReceive , data ) ;
263263
264264 private async void HandleDatagramReceive ( UdpReceiveResult obj )
265265 {
266- var @event = VoiceReceive ;
267- if ( @event is not null )
266+ var handlers = _voiceReceive ;
267+ if ( ! handlers . IsEmpty )
268268 {
269269 try
270270 {
0 commit comments