Allow joining specific channel on start

When mumsi connects to a mumble server, let it join a channel.
Therefore, callbacks for the channel list and the serversync (as connect
signal) are implemented.
This commit is contained in:
Matthias Larisch 2015-11-30 23:24:41 +01:00
parent 2475e6ce67
commit 4ba63178b3
4 changed files with 52 additions and 0 deletions

View File

@ -24,6 +24,8 @@ set(SOURCE_FILES
PjsuaCommunicator.hpp PjsuaCommunicator.hpp
MumbleCommunicator.cpp MumbleCommunicator.cpp
MumbleCommunicator.hpp MumbleCommunicator.hpp
MumbleChannelJoiner.cpp
MumbleChannelJoiner.hpp
Configuration.cpp Configuration.cpp
Configuration.hpp Configuration.hpp
IncomingConnectionValidator.cpp IncomingConnectionValidator.cpp

View File

@ -17,6 +17,28 @@ namespace mumble {
uint32_t pcm_data_size) override { uint32_t pcm_data_size) override {
communicator->onIncomingPcmSamples(sessionId, sequenceNumber, pcm_data, pcm_data_size); communicator->onIncomingPcmSamples(sessionId, sequenceNumber, pcm_data, pcm_data_size);
} }
virtual void channelState(
std::string name,
int32_t channel_id,
int32_t parent,
std::string description,
std::vector<uint32_t> links,
std::vector<uint32_t> inks_add,
std::vector<uint32_t> links_remove,
bool temporary,
int32_t position) override {
communicator->onIncomingChannelState(name, channel_id);
}
virtual void serverSync(
std::string welcome_text,
int32_t session,
int32_t max_bandwidth,
int64_t permissions) override {
communicator->onServerSync();
};
}; };
} }
@ -51,3 +73,7 @@ mumble::MumbleCommunicator::~MumbleCommunicator() {
void mumble::MumbleCommunicator::sendTextMessage(std::string message) { void mumble::MumbleCommunicator::sendTextMessage(std::string message) {
mum->sendTextMessage(message); mum->sendTextMessage(message);
} }
void mumble::MumbleCommunicator::joinChannel(int channel_id) {
mum->joinChannel(channel_id);
}

View File

@ -38,8 +38,18 @@ namespace mumble {
*/ */
std::function<void(int, int, int16_t *, int)> onIncomingPcmSamples; std::function<void(int, int, int16_t *, int)> onIncomingPcmSamples;
/**
* This callback is called when a channel state message (e.g. Channel
* information) is received. Arguments: channel_id, name
*/
std::function<void(std::string, int)> onIncomingChannelState;
std::function<void()> onServerSync;
void sendTextMessage(std::string message); void sendTextMessage(std::string message);
void joinChannel(int channel_id);
public: public:
boost::asio::io_service &ioService; boost::asio::io_service &ioService;

View File

@ -1,6 +1,7 @@
#include "PjsuaCommunicator.hpp" #include "PjsuaCommunicator.hpp"
#include "MumbleCommunicator.hpp" #include "MumbleCommunicator.hpp"
#include "IncomingConnectionValidator.hpp" #include "IncomingConnectionValidator.hpp"
#include "MumbleChannelJoiner.hpp"
#include "Configuration.hpp" #include "Configuration.hpp"
#include <log4cpp/FileAppender.hh> #include <log4cpp/FileAppender.hh>
@ -32,6 +33,8 @@ int main(int argc, char *argv[]) {
mumble::MumbleCommunicator mumbleCommunicator(ioService); mumble::MumbleCommunicator mumbleCommunicator(ioService);
mumble::MumbleChannelJoiner mumbleChannelJoiner(conf.getString("mumble.channelNameExpression"));
using namespace std::placeholders; using namespace std::placeholders;
pjsuaCommunicator.onIncomingPcmSamples = std::bind( pjsuaCommunicator.onIncomingPcmSamples = std::bind(
&mumble::MumbleCommunicator::sendPcmSamples, &mumble::MumbleCommunicator::sendPcmSamples,
@ -47,6 +50,17 @@ int main(int argc, char *argv[]) {
&pjsuaCommunicator, &pjsuaCommunicator,
_1, _2, _3, _4); _1, _2, _3, _4);
mumbleCommunicator.onIncomingChannelState = std::bind(
&mumble::MumbleChannelJoiner::checkChannel,
&mumbleChannelJoiner,
_1, _2);
mumbleCommunicator.onServerSync = std::bind(
&mumble::MumbleChannelJoiner::maybeJoinChannel,
&mumbleChannelJoiner,
&mumbleCommunicator);
mumbleCommunicator.connect( mumbleCommunicator.connect(
conf.getString("mumble.user"), conf.getString("mumble.user"),
conf.getString("mumble.password"), conf.getString("mumble.password"),