@@ -896,16 +896,18 @@ private protected override void OnConnected()
896896
897897 private ValueTask SendIdentifyAsync ( ConnectionState connectionState , PresenceProperties ? presence = null , CancellationToken cancellationToken = default )
898898 {
899- var serializedPayload = new GatewayPayloadProperties < GatewayIdentifyProperties > ( GatewayOpcode . Identify , new ( Token . RawToken )
899+ GatewayPayloadProperties < GatewayIdentifyProperties > payload = new ( GatewayOpcode . Identify , new ( Token . RawToken )
900900 {
901901 ConnectionProperties = _connectionProperties ,
902902 LargeThreshold = _largeThreshold ,
903903 Shard = Shard ,
904904 Presence = presence ?? _presence ,
905905 Intents = _intents ,
906- } ) . Serialize ( Serialization . Default . GatewayPayloadPropertiesGatewayIdentifyProperties ) ;
906+ } ) ;
907+
907908 _latencyTimer . Start ( ) ;
908- return SendConnectionPayloadAsync ( connectionState , serializedPayload , _internalTextPayloadProperties , cancellationToken ) ;
909+
910+ return SendConnectionObjectAsync ( connectionState , payload , Serialization . Default . GatewayPayloadPropertiesGatewayIdentifyProperties , _internalTextPayloadProperties , cancellationToken ) ;
909911 }
910912
911913 /// <summary>
@@ -948,16 +950,20 @@ private protected override ValueTask TryResumeAsync(ConnectionState connectionSt
948950
949951 private ValueTask TryResumeAsync ( ConnectionState connectionState , string sessionId , int sequenceNumber , CancellationToken cancellationToken = default )
950952 {
951- var serializedPayload = new GatewayPayloadProperties < GatewayResumeProperties > ( GatewayOpcode . Resume , new ( Token . RawToken , sessionId , sequenceNumber ) ) . Serialize ( Serialization . Default . GatewayPayloadPropertiesGatewayResumeProperties ) ;
953+ GatewayPayloadProperties < GatewayResumeProperties > payload = new ( GatewayOpcode . Resume , new ( Token . RawToken , sessionId , sequenceNumber ) ) ;
954+
952955 _latencyTimer . Start ( ) ;
953- return SendConnectionPayloadAsync ( connectionState , serializedPayload , _internalTextPayloadProperties , cancellationToken ) ;
956+
957+ return SendConnectionObjectAsync ( connectionState , payload , Serialization . Default . GatewayPayloadPropertiesGatewayResumeProperties , _internalTextPayloadProperties , cancellationToken ) ;
954958 }
955959
956960 private protected override ValueTask HeartbeatAsync ( ConnectionState connectionState , CancellationToken cancellationToken = default )
957961 {
958- var serializedPayload = new GatewayPayloadProperties < int > ( GatewayOpcode . Heartbeat , SequenceNumber ) . Serialize ( Serialization . Default . GatewayPayloadPropertiesInt32 ) ;
962+ GatewayPayloadProperties < int > payload = new ( GatewayOpcode . Heartbeat , SequenceNumber ) ;
963+
959964 _latencyTimer . Start ( ) ;
960- return SendConnectionPayloadAsync ( connectionState , serializedPayload , _internalTextPayloadProperties , cancellationToken ) ;
965+
966+ return SendConnectionObjectAsync ( connectionState , payload , Serialization . Default . GatewayPayloadPropertiesInt32 , _internalTextPayloadProperties , cancellationToken ) ;
961967 }
962968
963969 private protected override ValueTask ProcessPayloadAsync ( State state , ConnectionState connectionState , WebSocketMessageType messageType , ReadOnlySpan < byte > payload )
@@ -1037,7 +1043,8 @@ private async ValueTask HandlePayloadAsync(State state, ConnectionState connecti
10371043 public ValueTask UpdateVoiceStateAsync ( VoiceStateProperties voiceState , WebSocketPayloadProperties ? properties = null , CancellationToken cancellationToken = default )
10381044 {
10391045 GatewayPayloadProperties < VoiceStateProperties > payload = new ( GatewayOpcode . VoiceStateUpdate , voiceState ) ;
1040- return SendPayloadAsync ( payload . Serialize ( Serialization . Default . GatewayPayloadPropertiesVoiceStateProperties ) , properties , cancellationToken ) ;
1046+
1047+ return SendObjectAsync ( payload , Serialization . Default . GatewayPayloadPropertiesVoiceStateProperties , properties , cancellationToken ) ;
10411048 }
10421049
10431050 /// <summary>
@@ -1049,7 +1056,8 @@ public ValueTask UpdateVoiceStateAsync(VoiceStateProperties voiceState, WebSocke
10491056 public ValueTask UpdatePresenceAsync ( PresenceProperties presence , WebSocketPayloadProperties ? properties = null , CancellationToken cancellationToken = default )
10501057 {
10511058 GatewayPayloadProperties < PresenceProperties > payload = new ( GatewayOpcode . PresenceUpdate , presence ) ;
1052- return SendPayloadAsync ( payload . Serialize ( Serialization . Default . GatewayPayloadPropertiesPresenceProperties ) , properties , cancellationToken ) ;
1059+
1060+ return SendObjectAsync ( payload , Serialization . Default . GatewayPayloadPropertiesPresenceProperties , properties , cancellationToken ) ;
10531061 }
10541062
10551063 /// <summary>
@@ -1058,7 +1066,8 @@ public ValueTask UpdatePresenceAsync(PresenceProperties presence, WebSocketPaylo
10581066 public ValueTask RequestGuildUsersAsync ( GuildUsersRequestProperties requestProperties , WebSocketPayloadProperties ? properties = null , CancellationToken cancellationToken = default )
10591067 {
10601068 GatewayPayloadProperties < GuildUsersRequestProperties > payload = new ( GatewayOpcode . RequestGuildUsers , requestProperties ) ;
1061- return SendPayloadAsync ( payload . Serialize ( Serialization . Default . GatewayPayloadPropertiesGuildUsersRequestProperties ) , properties , cancellationToken ) ;
1069+
1070+ return SendObjectAsync ( payload , Serialization . Default . GatewayPayloadPropertiesGuildUsersRequestProperties , properties , cancellationToken ) ;
10621071 }
10631072
10641073 private async Task ProcessEventAsync ( State state , ConnectionState connectionState , JsonGatewayPayload payload )
0 commit comments