summaryrefslogtreecommitdiff
path: root/Source/Android/jni/NetPlay/Netplay.cpp
diff options
context:
space:
mode:
authorTom Pratt <tom.pratt@outlook.com>2026-05-06 13:35:34 +0200
committerTom Pratt <tompratt@squareup.com>2026-05-19 12:02:54 +0200
commit1464fdfc2845817b52c204b719e16975e5182fe5 (patch)
tree9647dfa0f53e3a3191910adb778502d39b776472 /Source/Android/jni/NetPlay/Netplay.cpp
parenta1983e5fa2f66911b7151e0fc8f90a86b7cece52 (diff)
Add NetPlayClient join and stub NetPlayUICallbacks
Diffstat (limited to 'Source/Android/jni/NetPlay/Netplay.cpp')
-rw-r--r--Source/Android/jni/NetPlay/Netplay.cpp25
1 files changed, 25 insertions, 0 deletions
diff --git a/Source/Android/jni/NetPlay/Netplay.cpp b/Source/Android/jni/NetPlay/Netplay.cpp
index 245a24852c..42ed6483ce 100644
--- a/Source/Android/jni/NetPlay/Netplay.cpp
+++ b/Source/Android/jni/NetPlay/Netplay.cpp
@@ -1,14 +1,17 @@
// Copyright 2003 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <memory>
#include <string>
#include <jni.h>
#include "Common/CommonTypes.h"
#include "Core/Config/NetplaySettings.h"
+#include "Core/NetPlayClient.h"
#include "jni/AndroidCommon/AndroidCommon.h"
+#include "jni/NetPlay/NetPlayUICallbacks.h"
extern "C" {
@@ -117,4 +120,26 @@ Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_SaveSetup(
Config::SetBaseOrCurrent(Config::NETPLAY_LISTEN_PORT, static_cast<u16>(listenPort));
}
+JNIEXPORT jlong JNICALL
+Java_org_dolphinemu_dolphinemu_features_netplay_Netplay_Join(JNIEnv*, jclass)
+{
+ const std::string traversal_choice = Config::Get(Config::NETPLAY_TRAVERSAL_CHOICE);
+ const bool is_traversal = traversal_choice == "traversal";
+
+ std::string host_ip;
+ host_ip = is_traversal ? Config::Get(Config::NETPLAY_HOST_CODE) :
+ Config::Get(Config::NETPLAY_ADDRESS);
+
+ const u16 host_port = Config::Get(Config::NETPLAY_CONNECT_PORT);
+ const std::string traversal_host = Config::Get(Config::NETPLAY_TRAVERSAL_SERVER);
+ const u16 traversal_port = Config::Get(Config::NETPLAY_TRAVERSAL_PORT);
+ const std::string nickname = Config::Get(Config::NETPLAY_NICKNAME);
+
+ auto* client = new NetPlay::NetPlayClient(
+ host_ip, host_port, new NetPlay::NetPlayUICallbacks(), nickname,
+ NetPlay::NetTraversalConfig{is_traversal, traversal_host, traversal_port});
+
+ return reinterpret_cast<jlong>(client);
+}
+
} // extern "C"