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

Channel description is searched for the string "fgcom-mumble enabled" to see if it should enable the plugin #54

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion README-de_DE.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ Das Plugin einsetzen
====================
- Verbinde dich auf den mumble server
- Aktiviere das FGCom-mumble plugin
- betrete einen Chatraum der mit `fgcom-mumble` beginnt
- betrete einen Chatraum der mit `fgcom-mumble` beginnt oder dessen Beschreibung `fgcom-mumble activated` enthält

Jetzt bist du bereit, am Funkverkehr teilzunehmen!
Dein Flugsimulator oder ATC-Programm muss dem Plugin nun die notwendigen Informationen senden, damit es weiß, wo du bist und welche Funkgeräte zur Verfügung stehen.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ Running the client
======================
- connect your mumble client to fgfs mumble server
- enable your plugin in your standard mumble client
- join a channel starting with `fgcom-mumble`
- join a channel starting with `fgcom-mumble` or with `fgcom-mumble activated` in its description.

You are ready for radio usage! Some client needs to supply information to the plugin now, so it knows about your location and radio stack.

Expand Down
34 changes: 26 additions & 8 deletions client/mumble-plugin/fgcom-mumble.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,11 +314,12 @@ mumble_error_t fgcom_loadConfig() {
std::string token_value = sm[2];
pluginDbg("[CFG] Parsing token: "+token_key+"="+token_value);

if (token_key == "radioAudioEffects") fgcom_cfg.radioAudioEffects = (token_value == "0" || token_value == "false" || token_value == "off")? false : true;
if (token_key == "radioAudioEffects") fgcom_cfg.radioAudioEffects = (token_value == "0" || token_value == "false" || token_value == "off")? false : true;
if (token_key == "allowHearingNonPluginUsers") fgcom_cfg.allowHearingNonPluginUsers = (token_value == "1" || token_value == "true" || token_value == "on")? true : false;
if (token_key == "specialChannel") fgcom_cfg.specialChannel = token_value;
if (token_key == "udpServerHost") fgcom_cfg.udpServerHost = token_value;
if (token_key == "udpServerPort") fgcom_cfg.udpServerPort = std::stoi(token_value);
if (token_key == "specialChannelName") fgcom_cfg.specialChannelName = token_value;
if (token_key == "specialChannelDescription") fgcom_cfg.specialChannelDescription = token_value;
if (token_key == "udpServerHost") fgcom_cfg.udpServerHost = token_value;
if (token_key == "udpServerPort") fgcom_cfg.udpServerPort = std::stoi(token_value);
}
}
} else {
Expand Down Expand Up @@ -428,28 +429,45 @@ mumble_error_t fgcom_initPlugin() {
return EC_CHANNEL_NOT_FOUND; // abort online init - something horribly went wrong.
} else {
pluginLog("Server has "+std::to_string(channelCount)+" channels, looking for special ones");
pluginDbg(" fgcom.specialChannel='"+fgcom_cfg.specialChannel+"'");
pluginDbg(" fgcom.specialChannelName='"+fgcom_cfg.specialChannelName+"'");
for (size_t ci=0; ci<channelCount; ci++) {
pluginDbg(" resolving channel name for id="+std::to_string(channels[ci]));
const char *channelName;
mumble_error_t cfres = mumAPI.getChannelName(ownPluginID, activeConnection, channels[ci], &channelName);
if (cfres == STATUS_OK) {
pluginDbg(" channelID="+std::to_string(channels[ci])+" '"+channelName+"'");
std::string channelName_str(channelName);
if (std::regex_match(channelName_str, std::regex(fgcom_cfg.specialChannel, std::regex_constants::icase) )) {
if (std::regex_match(channelName_str, std::regex(fgcom_cfg.specialChannelName, std::regex_constants::icase) )) {
fgcom_specialChannelID.push_back(channels[ci]);
pluginDbg(" special channel id found! name='"+channelName_str+"'; id="+std::to_string(channels[ci]));
}

pluginDbg(" resolving channel description for id="+std::to_string(channels[ci]));
const char *channelDesc;
mumble_error_t cdres = mumAPI.getChannelDescription(ownPluginID, activeConnection, channels[ci], &channelDesc);
if (cdres == STATUS_OK) {
pluginDbg(" channelDescription="+std::to_string(channels[ci])+" '"+channelDesc+"'");
std::string channelDesc_str(channelDesc);
if (std::regex_match(channelDesc_str, std::regex(fgcom_cfg.specialChannelDescription, std::regex_constants::icase) )) {
fgcom_specialChannelID.push_back(channels[ci]);
pluginDbg(" special channel id found! name='"+channelName_str+"'; id="+std::to_string(channels[ci]));
}
mumAPI.freeMemory(ownPluginID, channelName);
} else if (cdres == EC_UNSYNCHRONIZED_BLOB) {
pluginDbg(" channel description not synched yet for id="+std::to_string(channels[ci]));
}

mumAPI.freeMemory(ownPluginID, channelName);
} else {
pluginDbg("Error fetching channel names: rc="+std::to_string(cfres));
return EC_CHANNEL_NOT_FOUND; // abort online init - something horribly went wrong.
}

}

if (fgcom_specialChannelID.size() == 0) {
pluginLog("ERROR: FAILED TO RETRIEVE SPECIAL CHANNEL '"+fgcom_cfg.specialChannel+"'! Please setup such an channel.");
mumAPI.log(ownPluginID, std::string("Failed to retrieve special channel '"+fgcom_cfg.specialChannel+"'! Please setup such an channel.").c_str());
pluginLog("ERROR: FAILED TO RETRIEVE SPECIAL CHANNEL '"+fgcom_cfg.specialChannelName+"'! Please setup such an channel.");
mumAPI.log(ownPluginID, std::string("Failed to retrieve special channel '"+fgcom_cfg.specialChannelName+"'! Please setup such an channel.").c_str());
}
}
mumAPI.freeMemory(ownPluginID, channels);
Expand Down
5 changes: 4 additions & 1 deletion client/mumble-plugin/fgcom-mumble.ini
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@
;; The plugin will activate radio channel handling when inside this channel(s).
;; The parameter is a default ECMA regular expression (case ignore) and will match channel
;; names starting with the string "fgcom-mumble", optionally followed by anything.
;specialChannel=^fgcom-mumble.*
;; Additionally, also the channel descriptions are parsed; if the description matches
;; the regex given here, it will also activate the plugin.
;specialChannelName=^fgcom-mumble.*
;specialChannelDescription=fgcom-mumble activated


;; UDP listening host and port
Expand Down
12 changes: 7 additions & 5 deletions client/mumble-plugin/lib/globalVars.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,16 +36,18 @@
struct fgcom_config {
bool allowHearingNonPluginUsers;
bool radioAudioEffects;
std::string specialChannel;
std::string specialChannelName;
std::string specialChannelDescription;
std::string udpServerHost;
int udpServerPort;

fgcom_config() {
allowHearingNonPluginUsers = false;
radioAudioEffects = true;
specialChannel = "^fgcom-mumble.*";
udpServerHost = "127.0.0.1";
udpServerPort = 16661;
radioAudioEffects = true;
specialChannelName = "^fgcom-mumble.*";
specialChannelDescription = "fgcom-mumble activated";
udpServerHost = "127.0.0.1";
udpServerPort = 16661;
};
};
extern struct fgcom_config fgcom_cfg;
Expand Down
4 changes: 3 additions & 1 deletion client/plugin.spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ When leaving that special channel, the plugin enters some 'noop' state so it wil

Your local microphone will get switched to push-to-talk mode when entering the special channel (as well as restored when leaving it). When activating your flightsims PTT button on a radio, it will get switched on if that radio is operable.

FGCom-mumble activated channels can also be marked with the string `fgcom-mumble activated` in its description, but this is notorious unstable, because mumble does only sync channel comments <128 bytes currently. Longer comments will only be synched on-demand (when the user hovers with the mouse over the channel), which is too late for plugin initialization.


Internal state
--------------
Expand Down Expand Up @@ -48,7 +50,7 @@ Internal State Updates
----------------------
Communication between plugins is handled by mumbles internal plugin data interface.

When entering the `fgcom-mumble` channel, your client will broadcast its state (and following changes) to remote clients. Your client will then ask the already present clients in the channel for their state. Each remote client will then send his state to your client independently. (Both that actions will also occur if you activate your plugin while already inside the special channel).
When entering an plugin-enabled channel, your client will broadcast its state (and following changes) to remote clients. Your client will then ask the already present clients in the channel for their state. Each remote client will then send his state to your client independently. (Both that actions will also occur if you activate your plugin while already inside the special channel).

Notification of other clients take place on special events (like joining the channel or activating the plugin) and potentially when new data is recieved trough the UDP input interface:

Expand Down