mirror of
https://github.com/mii443/libdatachannel.git
synced 2025-08-22 23:25:33 +00:00
Fixed local and remote address getters with libjuice
This commit is contained in:
@ -135,14 +135,16 @@ void IceTransport::gatherLocalCandidates() {
|
|||||||
|
|
||||||
std::optional<string> IceTransport::getLocalAddress() const {
|
std::optional<string> IceTransport::getLocalAddress() const {
|
||||||
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
||||||
if (juice_get_selected_addresses(mAgent.get(), str, JUICE_MAX_ADDRESS_STRING_LEN, NULL, 0)) {
|
if (juice_get_selected_addresses(mAgent.get(), str, JUICE_MAX_ADDRESS_STRING_LEN, NULL, 0) ==
|
||||||
|
0) {
|
||||||
return std::make_optional(string(str));
|
return std::make_optional(string(str));
|
||||||
}
|
}
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
std::optional<string> IceTransport::getRemoteAddress() const {
|
std::optional<string> IceTransport::getRemoteAddress() const {
|
||||||
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
char str[JUICE_MAX_ADDRESS_STRING_LEN];
|
||||||
if (juice_get_selected_addresses(mAgent.get(), NULL, 0, str, JUICE_MAX_ADDRESS_STRING_LEN)) {
|
if (juice_get_selected_addresses(mAgent.get(), NULL, 0, str, JUICE_MAX_ADDRESS_STRING_LEN) ==
|
||||||
|
0) {
|
||||||
return std::make_optional(string(str));
|
return std::make_optional(string(str));
|
||||||
}
|
}
|
||||||
return nullopt;
|
return nullopt;
|
||||||
@ -495,6 +497,7 @@ std::optional<string> IceTransport::getLocalAddress() const {
|
|||||||
}
|
}
|
||||||
return nullopt;
|
return nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<string> IceTransport::getRemoteAddress() const {
|
std::optional<string> IceTransport::getRemoteAddress() const {
|
||||||
NiceCandidate *local = nullptr;
|
NiceCandidate *local = nullptr;
|
||||||
NiceCandidate *remote = nullptr;
|
NiceCandidate *remote = nullptr;
|
||||||
|
@ -113,6 +113,15 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
this_thread::sleep_for(3s);
|
this_thread::sleep_for(3s);
|
||||||
|
|
||||||
|
if (auto addr = pc1->localAddress())
|
||||||
|
cout << "Local address 1: " << *addr << endl;
|
||||||
|
if (auto addr = pc1->remoteAddress())
|
||||||
|
cout << "Remote address 1: " << *addr << endl;
|
||||||
|
if (auto addr = pc2->localAddress())
|
||||||
|
cout << "Local address 2: " << *addr << endl;
|
||||||
|
if (auto addr = pc2->remoteAddress())
|
||||||
|
cout << "Remote address 2: " << *addr << endl;
|
||||||
|
|
||||||
if (dc1->isOpen() && dc2->isOpen()) {
|
if (dc1->isOpen() && dc2->isOpen()) {
|
||||||
pc1->close();
|
pc1->close();
|
||||||
pc2->close();
|
pc2->close();
|
||||||
|
Reference in New Issue
Block a user