Esempio n. 1
0
        protected IEnumerable <string> GetHelloScopes(HelloType helloResponse)
        {
            var emptyHelloMatch = new HelloType[0];
            Func <IEnumerable <string>, IEnumerable <string> > scopesSplitter = (text) => null != text?text.SelectMany(s => s.Split(new[] { ' ' }, StringSplitOptions.RemoveEmptyEntries).Select(e => e.Trim())) : new string[0];

            return(helloResponse.Scopes != null ? scopesSplitter(helloResponse.Scopes.Text) : new string[0]);
        }
Esempio n. 2
0
        /// <summary>
        /// Validates incoming Hello message
        /// </summary>
        /// <param name="message">Hello message</param>
        /// <param name="reason">reason why message is invalid, null if message is valid</param>
        /// <returns>true, if message is valid</returns>
        protected bool ValidateHelloMessage(SoapMessage <HelloType> message, string[] scopes, out string reason)
        {
            bool mode1 = Features.Contains(Feature.DiscoveryTypesDnNetworkVideoTransmitter);
            bool mode2 = Features.Contains(Feature.DiscoveryTypesTdsDevice);
            bool res   = true;

            reason = null;
            try
            {
                //check Types namespace

                HelloType hello = message.Object;
                if (hello.Types == null)
                {
                    reason = Resources.ErrorNoTypes_Text;
                    return(false);
                }
                if (!DiscoveryUtils.CheckDeviceHelloType(message, out reason, mode1, mode2))
                {
                    return(false);
                }
                if (hello.EndpointReference == null)
                {
                    reason = Resources.ErrorNoEndpointReference_Text;
                    return(false);
                }
                if (hello.Scopes == null)
                {
                    reason = Resources.ErrorNoScopes_Text;
                    return(false);
                }
                if (hello.Scopes.Text == null)
                {
                    reason = Resources.ErrorNoScopesText_Text;
                    return(false);
                }
                //check mandatory scopes
                string missingScope = DiscoveryUtils.GetMissingMandatoryScope(hello.Scopes.Text);
                if (!string.IsNullOrEmpty(missingScope))
                {
                    reason = string.Format(Resources.ErrorMissingMandatoryScope_Format, missingScope);
                    return(false);
                }
                //check optional scopes
                if (scopes != null)
                {
                    missingScope = DiscoveryUtils.GetMissingScope(hello.Scopes.Text, scopes);
                    if (!string.IsNullOrEmpty(missingScope))
                    {
                        reason = string.Format(Resources.ErrorMissingScope_Format, missingScope);
                        return(false);
                    }
                }
            }
            catch (Exception e)
            {
                reason = e.Message;
                res    = false;
            }
            return(res);
        }
 public void Hello(HelloType type, string name)
 {
     Debug.Log(type + " " + name);
 }