internal void UpdateProperties(SocketEndpointProperties theNewProperties)
        {
            bool SubscriptionsUpdatedFlag = false;
            bool EventsUpdatedFlag        = false;
            bool ForceInitialise          = false;

            if (theNewProperties.Guid == null || theNewProperties.Guid != Guid)
            {
                return;
            }

            if (theNewProperties.ReadEvent != null)
            {
                if (Event.Merge(ReadEvent, theNewProperties.ReadEvent))
                {
                    EventsUpdatedFlag = true;
                }
            }

            if (theNewProperties.IPAddress != null && theNewProperties.IPAddress != IPAddress)
            {
                IPAddress       = theNewProperties.IPAddress;
                ForceInitialise = true;
            }

            if (theNewProperties.Port != -1 && theNewProperties.Port != Port)
            {
                Port            = theNewProperties.Port;
                ForceInitialise = true;
            }

            if (theNewProperties.Backlog != -1 && theNewProperties.Backlog != Backlog)
            {
                Backlog         = theNewProperties.Backlog;
                ForceInitialise = true;
            }

            if (theNewProperties.LoggingLevel != -1 && theNewProperties.LoggingLevel != LoggingLevel)
            {
                LoggingLevel = theNewProperties.LoggingLevel;
            }

            if (theNewProperties.NICIndex != -1 && theNewProperties.NICIndex != NICIndex)
            {
                NICIndex = theNewProperties.NICIndex;
            }

            int NICIndexSearch = LocalIPAddressList.GetIndex(IPAddress);

            if (NICIndexSearch != -1)
            {
                NICIndex = NICIndexSearch;
            }

            if (theNewProperties.WriteSubscriptions != null)
            {
                List <Subscription> NewSubscriptions = new List <Subscription>();

                foreach (Subscription Subscription in theNewProperties.WriteSubscriptions)
                {
                    Subscription Search = WriteSubscriptions.FirstOrDefault(ne => ne.Guid == Subscription.Guid);

                    if (Search == null)
                    {
                        NewSubscriptions.Add(Subscription);
                    }
                    else
                    {
                        if (Subscription.Merge(Search, Subscription))
                        {
                            SubscriptionsUpdatedFlag = true;
                        }
                    }
                }

                if (NewSubscriptions.Count() > 0)
                {
                    SubscriptionsUpdatedFlag = true;
                }

                foreach (Subscription Subscription in NewSubscriptions)
                {
                    Subscription.Guid   = System.Guid.NewGuid().ToString();
                    Subscription.Event += m_Listener.OnSubscriptionEvent;
                }

                List <Subscription> List = WriteSubscriptions == null ? new List <Subscription>() : WriteSubscriptions.ToList();

                List.AddRange(NewSubscriptions);
                WriteSubscriptions = List.ToArray();
            }

            if (EventsUpdatedFlag)
            {
                EventsUpdated?.Invoke();
            }

            if (SubscriptionsUpdatedFlag)
            {
                SubscriptionsUpdated?.Invoke();
            }

            if (ForceInitialise)
            {
                InitialiseSetup();
            }
        }
Exemple #2
0
 public SocketEndpointListener(SocketEndpointProperties theProperties)
 {
     m_Properties = theProperties;
 }