MCPcopy Create free account
hub / github.com/WarmUpTill/SceneSwitcher / StartServerMigrationClient

Method StartServerMigrationClient

plugins/twitch/event-sub.cpp:509–555  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

507}
508
509void EventSub::StartServerMigrationClient(const std::string &url)
510{
511 _migrationClient = std::make_unique<EventSubWSClient>();
512 SetupClient(*_migrationClient);
513
514 _migrationClient->set_open_handler([this](connection_hdl) {
515 vblog(LOG_INFO, "Twitch EventSub migration client opened");
516 });
517
518 _migrationClient->set_message_handler([this](connection_hdl hdl,
519 EventSubWSClient::message_ptr
520 message) {
521 const auto msg = ParseWebSocketMessage(message);
522 if (!msg) {
523 return;
524 }
525
526 const auto &type = msg->type;
527 const auto &data = msg->payload;
528
529 if (type == "session_welcome") {
530 blog(LOG_INFO,
531 "Twitch EventSub migration successful - switching to new connection");
532 OBSDataAutoRelease session =
533 obs_data_get_obj(data, "session");
534 _migrationSessionID =
535 obs_data_get_string(session, "id");
536 OnServerMigrationWelcome(hdl, _migrationClient);
537 } else {
538 OnMessage(hdl, message);
539 }
540 });
541
542 websocketpp::lib::error_code ec;
543 auto con = _migrationClient->get_connection(url, ec);
544 if (ec) {
545 blog(LOG_ERROR,
546 "Twitch EventSub migration connection failed: %s",
547 ec.message().c_str());
548 _migrating = false;
549 return;
550 }
551
552 _migrationConnection = con;
553 _migrationClient->connect(con);
554 _migrationClient->run();
555}
556
557void EventSub::HandleServerMigration(obs_data_t *data)
558{

Callers

nothing calls this directly

Calls 2

c_strMethod · 0.45
runMethod · 0.45

Tested by

no test coverage detected