Skip to content

Commit

Permalink
Allow multiple Settings objects
Browse files Browse the repository at this point in the history
  • Loading branch information
pcgod committed Mar 7, 2010
1 parent df82a1e commit 8348efa
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 23 deletions.
12 changes: 6 additions & 6 deletions client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ MumbleClient::~MumbleClient() {

void MumbleClient::Connect(const Settings& s) {
// Resolve hostname
std::cerr << "Resolving host " << s.getHost() << std::endl;
std::cerr << "Resolving host " << s.GetHost() << std::endl;

tcp::resolver resolver(*io_service_);
tcp::resolver::query query(s.getHost(), s.getPort());
tcp::resolver::query query(s.GetHost(), s.GetPort());
tcp::resolver::iterator endpoint_iterator = resolver.resolve(query);
tcp::resolver::iterator end;

Expand Down Expand Up @@ -188,13 +188,13 @@ void MumbleClient::Connect(const Settings& s) {
// Send initial messages
MumbleProto::Version v;
v.set_version(MUMBLE_VERSION(1, 2, 2));
v.set_release("0.0.1-dev");
v.set_release("libmumbleclient 0.0.1-dev");
SendMessage(PbMessageType::Version, v, true);

MumbleProto::Authenticate a;
a.set_username(s.getUserName());
a.set_password(s.getPassword());
// FIXME: hardcoded version number
a.set_username(s.GetUserName());
a.set_password(s.GetPassword());
// FIXME(pcgod): hardcoded version number
a.add_celt_versions(0x8000000b);
SendMessage(PbMessageType::Authenticate, a, true);

Expand Down
6 changes: 4 additions & 2 deletions main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ void RawUdpTunnelCallback(int32_t length, void* buffer) {

int main(int /* argc */, char** /* argv[] */) {
MumbleClient::MumbleClientLib* mcl = MumbleClient::MumbleClientLib::instance();
MumbleClient::Settings s;

// Create a new client
MumbleClient::MumbleClient* mc = mcl->NewClient();
mc->Connect(s);
mc->Connect(MumbleClient::Settings("0xy.org", "64739", "testBot", ""));

mc->SetAuthCallback(boost::bind(&AuthCallback));
mc->SetTextMessageCallback(boost::bind(&TextMessageCallback, _1, mc));
mc->SetRawUdpTunnelCallback(boost::bind(&RawUdpTunnelCallback, _1, _2));

// MumbleClient::MumbleClient* mc2 = mcl->NewClient();
// mc2->Connect(MumbleClient::Settings("0xy.org", "64739", "testBot2", ""));

// Start event loop
mcl->Run();
}
33 changes: 18 additions & 15 deletions settings.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@ namespace MumbleClient {

class Settings {
public:
std::string getHost() const {
return "0xy.de";
}
Settings(const std::string& host, const std::string& port,
const std::string& user_name, const std::string& password) :
host_(host),
port_(port),
user_name_(user_name),
password_(password) { }

std::string getPort() const {
return "64739";
}
std::string GetHost() const { return host_; }
std::string GetPort() const { return port_; }
std::string GetUserName() const { return user_name_; }
std::string GetPassword() const { return password_; }

std::string getUserName() const {
return "testBot";
}
void SetHost(const std::string& host) { host_ = host; }
void SetPort(const std::string& port) { port_ = port; }
void SetUserName(const std::string& user_name) { user_name_ = user_name; }
void SetPassword(const std::string& password) { password_ = password; }

std::string getPassword() const {
return "";
}
/*
private:
Settings();
std::string host_;
std::string port_;
std::string user_name_;
std::string password_;
Settings(const Settings&);
void operator=(const Settings&);
*/
};

} // end namespace MumbleClient
Expand Down

0 comments on commit 8348efa

Please sign in to comment.