Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added channel_url option to set splitter address and port from channel description #22

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 22 additions & 3 deletions src/peer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -412,6 +412,7 @@ namespace p2psp {
uint16_t player_port = Console::GetDefaultPlayerPort();
std::string splitter_addr = p2psp::Peer_core::GetDefaultSplitterAddr().to_string();
uint16_t splitter_port = p2psp::Peer_core::GetDefaultSplitterPort();
std::string channel_url;
#if not defined __IMS__
int max_chunk_debt = p2psp::Peer_DBS::GetDefaultMaxChunkDebt();
uint16_t team_port = p2psp::Peer_core::GetDefaultTeamPort();
Expand All @@ -423,6 +424,7 @@ namespace p2psp {
// TODO: strpe option should expect a list of arguments, not bool
desc.add_options()
("help,h", "Produce this help message and exits.")
("channel_url", boost::program_options::value<std::string>(), "Channel url to get splitter address from crossroads engine")
#if not defined __IMS__
("max_chunk_debt", boost::program_options::value<int>()->default_value(max_chunk_debt), "Maximum number of times that other peer can not send a chunk to this peer.")
#endif
Expand Down Expand Up @@ -501,6 +503,7 @@ namespace p2psp {
class Console* peer = new Console();

// }}}


if (vm.count("smart_source_client")) {
// {{{
Expand All @@ -518,13 +521,29 @@ namespace p2psp {

// }}}
}

if (vm.count("channel_url")) {

TRACE("Channel URL = "
<< vm["channel_url"].as<std::string>());
std::string splitter_source = peer->RESTSplitter(vm["channel_url"].as<std::string>());
int delimeter=splitter_source.find(":");
std::string splitter_addr = splitter_source.substr(0,delimeter);
std::string splitter_port=splitter_source.substr(delimeter+1);
peer->SetSplitterAddr(ip::address::from_string("127.0.0.1"));
TRACE("Splitter address = "
<< peer->GetSplitterAddr());
peer->SetSplitterPort(std::stoi(splitter_port));
TRACE("Splitter port = "
<< peer->GetSplitterPort());
}

peer->WaitForThePlayer();
std::cout
<< "Player connected"
<< std::endl;


if (vm.count("splitter_addr")) {
if (vm.count("splitter_addr") && !(vm.count("channel_url"))) {
// {{{

peer->SetSplitterAddr(ip::address::from_string(vm["splitter_addr"].as<std::string>()));
Expand All @@ -534,7 +553,7 @@ namespace p2psp {
// }}}
}

if (vm.count("splitter_port")) {
if (vm.count("splitter_port") && !(vm.count("channel_url"))) {
// {{{

peer->SetSplitterPort(vm["splitter_port"].as<uint16_t>());
Expand Down