88#include " Common/Cpp/PrettyPrint.h"
99// #include "Common/Cpp/Exceptions.h"
1010#include " Common/PABotBase2/PABotBase2CC_MessageDumper.h"
11+ #include " CommonTools/Random.h"
1112// #include "PABotBase2_ConnectionDebug.h"
1213#include " PABotBase2CC_ReliableStreamConnection.h"
1314
@@ -32,7 +33,7 @@ ReliableStreamConnection::ReliableStreamConnection(
3233 , m_unreliable_connection(unreliable_connection)
3334 , m_retransmit_timeout(retransmit_timeout)
3435 , m_print_lock(print_lock)
35- , m_reliable_sender(*this , 20 )
36+ , m_reliable_sender(*this , 24 , random_u32() )
3637 , m_log_everything(log_everything)
3738// , m_version_verified(false)
3839 , m_remote_protocol_compatible(false )
@@ -123,7 +124,11 @@ void ReliableStreamConnection::on_recv(const void* data, size_t bytes){
123124 cout << "ReliableStreamConnection::on_recv(): " << bytes << endl;
124125 }
125126#endif
126- m_parser.push_bytes (*this , (const uint8_t *)data, bytes);
127+ m_parser.push_bytes (
128+ *this ,
129+ m_reliable_sender.session_id (),
130+ (const uint8_t *)data, bytes
131+ );
127132}
128133
129134
@@ -168,11 +173,11 @@ size_t ReliableStreamConnection::unreliable_send(const void* data, size_t bytes)
168173bool ReliableStreamConnection::reset (WallDuration timeout){
169174 {
170175 std::lock_guard<Mutex> lg (m_lock);
171- m_reliable_sender.reset ();
176+ m_reliable_sender.reset (m_reliable_sender. session_id () + 1 );
172177 m_parser.reset ();
173178 m_stream_coalescer.reset ();
174179 throw_if_cancelled ();
175- m_reliable_sender.send_packet ( PABB2_CONNECTION_OPCODE_ASK_RESET , 0 , nullptr );
180+ m_reliable_sender.send_reset ( );
176181 }
177182 m_cv.notify_all ();
178183 return wait_for_pending (timeout);
@@ -217,7 +222,7 @@ void ReliableStreamConnection::send_ack(uint8_t seqnum, uint8_t opcode){
217222 packet.header .seqnum = seqnum;
218223 packet.header .packet_bytes = sizeof (packet);
219224 packet.header .opcode = opcode;
220- pabb_crc32_write_to_message (&packet, sizeof (packet));
225+ pabb_crc32_write_to_message (m_reliable_sender. session_id (), &packet, sizeof (packet));
221226 unreliable_send (&packet, sizeof (packet));
222227}
223228void ReliableStreamConnection::send_ack_u16 (uint8_t seqnum, uint8_t opcode, uint16_t data){
@@ -231,7 +236,7 @@ void ReliableStreamConnection::send_ack_u16(uint8_t seqnum, uint8_t opcode, uint
231236 packet.header .packet_bytes = sizeof (packet);
232237 packet.header .opcode = opcode;
233238 packet.header .data = data;
234- pabb_crc32_write_to_message (&packet, sizeof (packet));
239+ pabb_crc32_write_to_message (m_reliable_sender. session_id (), &packet, sizeof (packet));
235240 unreliable_send (&packet, sizeof (packet));
236241}
237242
@@ -376,6 +381,7 @@ void ReliableStreamConnection::on_packet(const PacketHeader* packet){
376381 case PABB2_CONNECTION_OPCODE_INFO_LABEL_H32 :
377382 case PABB2_CONNECTION_OPCODE_INFO_LABEL_U32 :
378383 case PABB2_CONNECTION_OPCODE_INFO_LABEL_I32 :
384+ // case PABB2_CONNECTION_OPCODE_WRONG_SESSION:
379385// cout << "Received ack" << endl;
380386 if (!m_log_everything){
381387 m_logger.log (" [RSC]: Receive: (0x" + tostr_hex (packet->opcode ) + " ) " + tostr (packet), COLOR_PURPLE );
0 commit comments