예제 #1
0
        private void OnIsSoloPlayActiveChanged()
        {
            if (_initializing)
            {
                return;
            }

            // If the rule is indeed active. Remove FW rule. Check if still is active. Then do UI changed based on that.
            if (IsSoloPlayActive)
            {
                // Name. Portrange. Outbound yes/no. UDP yes/no.
                Soloplay.CreateFWRule(ruleName: fwRuleName, portValue: portRangeToBlock, isOut: true, isUDP: true);
                Soloplay.CreateFWRule(ruleName: fwRuleName, portValue: portRangeToBlock, isOut: true, isUDP: false);
                Soloplay.CreateFWRule(ruleName: fwRuleName, portValue: portRangeToBlock, isOut: false, isUDP: true);
                Soloplay.CreateFWRule(ruleName: fwRuleName, portValue: portRangeToBlock, isOut: false, isUDP: false);
            }

            // If the rule is not active. We then add the FW rules. Check if they now exist. Then do UI changed based on that.
            else
            {
                Soloplay.RemoveFirewallRule(fwRuleName);
                IsSoloPlayActive = Soloplay.DoesFWRuleExist(fwRuleName);
            }
        }