get port from tox
This commit is contained in:
parent
e8d8e10980
commit
3fb3b449c9
@ -29,10 +29,11 @@ SOLANA_PLUGIN_EXPORT uint32_t solana_plugin_start(struct SolanaAPI* solana_api)
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO: toxI
|
// TODO: toxI
|
||||||
|
auto* tox_i = PLUG_RESOLVE_INSTANCE(ToxI);
|
||||||
|
|
||||||
// static store, could be anywhere tho
|
// static store, could be anywhere tho
|
||||||
// construct with fetched dependencies
|
// construct with fetched dependencies
|
||||||
g_tox_upnp = std::make_unique<ToxUPnP>();
|
g_tox_upnp = std::make_unique<ToxUPnP>(*tox_i);
|
||||||
|
|
||||||
// register types
|
// register types
|
||||||
PLUG_PROVIDE_INSTANCE(ToxUPnP, plugin_name, g_tox_upnp.get());
|
PLUG_PROVIDE_INSTANCE(ToxUPnP, plugin_name, g_tox_upnp.get());
|
||||||
|
@ -13,5 +13,6 @@ target_include_directories(solanaceae_tox_upnp PUBLIC .)
|
|||||||
target_compile_features(solanaceae_tox_upnp PUBLIC cxx_std_17)
|
target_compile_features(solanaceae_tox_upnp PUBLIC cxx_std_17)
|
||||||
target_link_libraries(solanaceae_tox_upnp PUBLIC
|
target_link_libraries(solanaceae_tox_upnp PUBLIC
|
||||||
miniupnpc::miniupnpc
|
miniupnpc::miniupnpc
|
||||||
|
solanaceae_toxcore_interface
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -8,8 +8,13 @@
|
|||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
|
||||||
ToxUPnP::ToxUPnP(void) {
|
ToxUPnP::ToxUPnP(ToxI& tox) {
|
||||||
// get tox port
|
// get tox port
|
||||||
|
auto [port_opt, _] = tox.toxSelfGetUDPPort();
|
||||||
|
if (!port_opt.has_value()) {
|
||||||
|
return; // oof
|
||||||
|
}
|
||||||
|
_local_port = port_opt.value();
|
||||||
|
|
||||||
// start upnp thread
|
// start upnp thread
|
||||||
_thread = std::thread([this](void) {
|
_thread = std::thread([this](void) {
|
||||||
|
@ -4,16 +4,16 @@
|
|||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
class ToxUPnP {
|
#include <solanaceae/toxcore/tox_interface.hpp>
|
||||||
// TODO: ToxI& _t;
|
|
||||||
|
|
||||||
|
class ToxUPnP {
|
||||||
uint16_t _local_port {33445};
|
uint16_t _local_port {33445};
|
||||||
|
|
||||||
std::atomic_bool _quit {false};
|
std::atomic_bool _quit {false};
|
||||||
std::thread _thread;
|
std::thread _thread;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ToxUPnP(void);
|
ToxUPnP(ToxI& tox);
|
||||||
~ToxUPnP(void);
|
~ToxUPnP(void);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user