Skip to content

Commit

Permalink
session transmission: only send spectate start msg once
Browse files Browse the repository at this point in the history
  • Loading branch information
blueminder committed Jul 11, 2024
1 parent 7613ff6 commit e8cf311
Showing 1 changed file with 74 additions and 29 deletions.
103 changes: 74 additions & 29 deletions core/dojo/DojoSession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1702,43 +1702,49 @@ void DojoSession::transmitter_thread()

for (;;)
{
asio::write(socket, asio::buffer(spectate_start_message));

if (config::SpectatorIP.get() == "ggpo.fightcade.com")
if (config::TransmitScore && !start_sent)
{
// read player info reply
char header_buf[HEADER_LEN] = { 0 };
std::vector<unsigned char> body_buf;
int offset = 0;
asio::write(socket, asio::buffer(spectate_start_message));

// read header
memset((void*)header_buf, 0, HEADER_LEN);
try
{
asio::read(socket, asio::buffer(header_buf, HEADER_LEN));
}
catch (const std::system_error& e)
if (config::SpectatorIP.get() == "ggpo.fightcade.com")
{
//break;
}
// read player info reply
char header_buf[HEADER_LEN] = { 0 };
std::vector<unsigned char> body_buf;
int offset = 0;

// read header
memset((void*)header_buf, 0, HEADER_LEN);
try
{
asio::read(socket, asio::buffer(header_buf, HEADER_LEN));
}
catch (const std::system_error& e)
{
//break;
}

unsigned int body_size = HeaderReader::GetSize((unsigned char*)header_buf);
unsigned int cmd = HeaderReader::GetCmd((unsigned char*)header_buf);
unsigned int body_size = HeaderReader::GetSize((unsigned char*)header_buf);
unsigned int cmd = HeaderReader::GetCmd((unsigned char*)header_buf);

// read body
body_buf.resize(body_size);
// read body
body_buf.resize(body_size);

try
{
asio::read(socket, asio::buffer(body_buf, body_size));
}
catch (const std::system_error& e)
{
//break;
try
{
asio::read(socket, asio::buffer(body_buf, body_size));
}
catch (const std::system_error& e)
{
//break;
}
offset = 0;

dojo.ProcessBody(cmd, body_size, (const char*)body_buf.data(), &offset);
}
offset = 0;

dojo.ProcessBody(cmd, body_size, (const char*)body_buf.data(), &offset);
std::cout << "Score Transmission Started" << std::endl;
start_sent = true;
}

if (config::Transmitting)
Expand All @@ -1762,6 +1768,45 @@ void DojoSession::transmitter_thread()
// delay start message until first frame batch
if (!start_sent && transmit_frame_count == FRAME_BATCH)
{
asio::write(socket, asio::buffer(spectate_start_message));

if (config::SpectatorIP.get() == "ggpo.fightcade.com")
{
// read player info reply
char header_buf[HEADER_LEN] = { 0 };
std::vector<unsigned char> body_buf;
int offset = 0;

// read header
memset((void*)header_buf, 0, HEADER_LEN);
try
{
asio::read(socket, asio::buffer(header_buf, HEADER_LEN));
}
catch (const std::system_error& e)
{
//break;
}

unsigned int body_size = HeaderReader::GetSize((unsigned char*)header_buf);
unsigned int cmd = HeaderReader::GetCmd((unsigned char*)header_buf);

// read body
body_buf.resize(body_size);

try
{
asio::read(socket, asio::buffer(body_buf, body_size));
}
catch (const std::system_error& e)
{
//break;
}
offset = 0;

dojo.ProcessBody(cmd, body_size, (const char*)body_buf.data(), &offset);
}

// clear local match code after transmission starts
config::MatchCode = "";
cfgSaveStr("dojo", "MatchCode", "");
Expand Down

0 comments on commit e8cf311

Please sign in to comment.